Re: Best way to get the latest revision from a table

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Best way to get the latest revision from a table
Дата
Msg-id 4D3088E70200002500039632@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: Best way to get the latest revision from a table  (Shaun Thomas <sthomas@peak6.com>)
Ответы Re: Best way to get the latest revision from a table  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Shaun Thomas <sthomas@peak6.com> wrote:

> This actually looks like a perfect candidate for DISTINCT ON.
>
> SELECT DISTINCT ON (a, b) a, b, revision
>    FROM test
>   ORDER BY a, b DESC;

I wouldn't say perfect.  It runs about eight times slower than what
I suggested and returns a fairly random value for revision instead
of the max(revision).

-Kevin

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

Предыдущее
От: Shaun Thomas
Дата:
Сообщение: Re: Best way to get the latest revision from a table
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Best way to get the latest revision from a table