Re: [SQL] How to get last 10 rows in a table on a large database?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] How to get last 10 rows in a table on a large database?
Дата
Msg-id 2549.941912218@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [SQL] How to get last 10 rows in a table on a large database?  (Stoyan Genov <genov@digsys.bg>)
Ответы Move forward all (Was Re: How to get last 10 rows in a table on a large database?)  (Stoyan Genov <genov@digsys.bg>)
Список pgsql-sql
Stoyan Genov <genov@digsys.bg> writes:
> You are unable to say:
>     begin transaction;
>         declare tbl_cur cursor for .... .....
>         move forward all in tbl_cur;
>         fetch backward 10 in tbl_cur;
>         ...........
>     end transaction;
> because when you "move forward all" the result gets lost.

Huh?  It seems to work fine for me.

However, the "move" is a tad slow since the silly thing actually scans
over all the tuples in index order :-(.  This might not be a useful
solution for Alex's problem after all, because of the time taken by
the "move".
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] How to get last 10 rows in a table on a large database?
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: [SQL] How to get last 10 rows in a table on a large database?