| From: | "fstelpstra(at)yahoo(dot)com" <fstelpstra(at)yahoo(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Can this query be optimized? |
| Date: | 2001-11-09 00:26:32 |
| Message-ID: | 9sf7m2$if1$1@news1.xs4all.nl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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(at)gmx(dot)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(at)postgresql(dot)org)
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | fstelpstra@yahoo.com | 2001-11-09 00:32:46 | Re: Design Tool for postgresql |
| Previous Message | Oleg Lebedev | 2001-11-08 22:45:44 | substring replacement |