Re: Picking out the most recent row using a time stamp column

Поиск
Список
Период
Сортировка
От Shaun Thomas
Тема Re: Picking out the most recent row using a time stamp column
Дата
Msg-id 4D66FEB9.6000501@peak6.com
обсуждение исходный текст
Ответ на Re: Picking out the most recent row using a time stamp column  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: Picking out the most recent row using a time stamp column
Список pgsql-performance
On 02/24/2011 06:20 PM, Josh Berkus wrote:

> SELECT id_key, time_stamp, value
> FROM (
>     SELECT id_key, time_stamp, value,
>         row_number()
>         OVER ( PARTITION BY id_key
>             ORDER BY time_stamp DESC)
>           as ranking
>     FROM thetable
>        ) as filtered_table
> WHERE ranking = 1

Why did you use row_number instead of rank?

I am now curious how the speed compares though. I still think the
DISTINCT ON will be faster, but it would be a great surprise.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas@peak6.com

______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

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

Предыдущее
От: Jochen Erwied
Дата:
Сообщение: Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Picking out the most recent row using a time stamp column