Re: [GENERAL] Query is not using index when it should

Поиск
Список
Период
Сортировка
От Steinar H. Gunderson
Тема Re: [GENERAL] Query is not using index when it should
Дата
Msg-id 20041211143213.GA2659@uio.no
обсуждение исходный текст
Ответ на Re: [GENERAL] Query is not using index when it should  (tomas@nocrew.org (Tomas Skäre))
Ответы Re: [GENERAL] Query is not using index when it should  (Michael Fuhr <mike@fuhr.org>)
Re: [GENERAL] Query is not using index when it should  (tomas@nocrew.org (Tomas Skäre))
Список pgsql-performance
On Sat, Dec 11, 2004 at 03:17:13PM +0100, Tomas Skäre wrote:
> select c.* from cjm_object c
>  inner join
>   (select max(timestamp) as timestamp,objectid,field from cjm_object
>    group by objectid,field) t
>   using(timestamp,objectid,field)
>  where 1=1 and data is not null
>  order by objectid,field;

Usually, SELECT max(field) FROM table is better written in PostgreSQL as
SELECT field FROM table ORDER field DESC LIMIT 1.

I don't see the point of "where 1=1", though...

/* Steinar */
--
Homepage: http://www.sesse.net/

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

Предыдущее
От: tomas@nocrew.org (Tomas Skäre)
Дата:
Сообщение: Re: [GENERAL] Query is not using index when it should
Следующее
От: Mike Rylander
Дата:
Сообщение: Re: LIMIT causes SEQSCAN in subselect