pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: fstelpstra@yahoo.com <fstelpstra@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Can this query be optimized?
Date: Fri, 9 Nov 2001 01:26:32 +0100
Message-ID: <9sf7m2$if1$1@news1.xs4all.nl> (raw)
References: <16760.1005229805@sss.pgh.pa.us>

Hi,

Isn't it much faster if you extract a substring from the date field?
For example if the date field returns 2001/12/30, you could use the 4th and 
5th position for the month part.

regards,
freek

Tom Lane wrote:

> Claus Heiko Niesen <cniesen@gmx.net> writes:
>> I'm stuck optimizing the following query:
>> select distinct extract(year from date) as year, extract(month from date)
>> as month, date from week_pics order by date desc;
> 
> Perhaps it would work to forget the "distinct" and instead GROUP BY
> date.
> 
> regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 




view thread (7+ messages)

Message-ID: <9sf7m2$if1$1@news1.xs4all.nl>
Permalink:  ../9sf7m2$if1$1@news1.xs4all.nl/
Also on:    postgresql.org/message-id/9sf7m2$if1$1@news1.xs4all.nl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fstelpstra@yahoo.com
  Subject: Re: Can this query be optimized?
  In-Reply-To: <9sf7m2$if1$1@news1.xs4all.nl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox