Re: Can this query be optimized?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Can this query be optimized?
Дата
Msg-id web-501647@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Re: Can this query be optimized?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Can this query be optimized?  (Claus Heiko Niesen <cniesen@gmx.net>)
Список pgsql-sql
Claus,

> > 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.

Also, do the following:
-- Make sure you have an index on week_pics.date 
(Tom, did you guys ever straignten out the issue with DESC sorts on
indexes?)
-- Build the above query as a VIEW, which should improve performance
somewhat.

Technically, you could build an index on extract(month from date), I
believe, but I'm not sure how effective such an index would be in
practice.

-Josh

______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: help with function and quotes
Следующее
От: Claus Heiko Niesen
Дата:
Сообщение: Re: Can this query be optimized?