Re: Order-by and indexes

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Order-by and indexes
Дата
Msg-id 6005.1309360004@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Order-by and indexes  (Odd Hogstad <odd.hogstad@smartm.no>)
Список pgsql-novice
Odd Hogstad <odd.hogstad@smartm.no> writes:
> I need to get the latest entry of a large table matching a certain criteria.
> This is my query:

> SELECT * FROM "data" WHERE "data"."fk" = 238496 ORDER BY "data"."id" DESC
> LIMIT 1

A two-column index on (fk, id) would help for this.  If you think about
the ordering of the index entries you'll see why.

            regards, tom lane

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

Предыдущее
От: "Jean-Yves F. Barbier"
Дата:
Сообщение: Re: Order-by and indexes
Следующее
От: Vincent Ficet
Дата:
Сообщение: pg_advisory_locks in a multithreaded application context