Can this query be optimized?

Поиск
Список
Период
Сортировка
От Claus Heiko Niesen
Тема Can this query be optimized?
Дата
Msg-id 5.1.0.14.2.20011107144418.00a83b68@pop.gmx.net
обсуждение исходный текст
Ответы Re: Can this query be optimized?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
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;

The table "week_pics" contains the column "date" which is indexed in 
descending order.  Unfortunately postresql isn't using the index since I'm 
using extract and order by the resulting values.  Instead postgresql will 
sort the result set.  To order by the date implies that the date needs to 
be in my select statement,  which interferes with uniqueness of the 
year-month pair.

Is there anything I could do to optimize this query besides breaking the 
date into three separate columns?
  Claus



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

Предыдущее
От: "fstelpstra@yahoo.com"
Дата:
Сообщение: Re: Design Tool for postgresql
Следующее
От: "John D. Rozeboom"
Дата:
Сообщение: Re: Need help with embedded CASEs