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

Поиск
Список
Период
Сортировка
От Stoyan Genov
Тема Re: [SQL] How to get last 10 rows in a table on a large database?
Дата
Msg-id 199911061136.NAA00556@lorna.digsys.bg
обсуждение исходный текст
Ответ на How to get last 10 rows in a table on a large database?  (Alex@Icepick.com (Alex))
Ответы Re: [SQL] How to get last 10 rows in a table on a large database?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hi.
You should try this:begin transaction;    declare tbl_cur cursor for select * from table order by datetime ASC;
fetchforward 10 in tbl_cur;end transaction;
 

This is true if you want THE LAST 10 rows from the selection - you order it
in reverse and get the first 10. You are unable to say:begin transaction;    declare tbl_cur cursor for .... .....
moveforward all in tbl_cur;    fetch backward 10 in tbl_cur;    ...........end transaction;
 
because when you "move forward all" the result gets lost.

If something is unclear, do write back...

Stoyan Genov



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

Предыдущее
От: Alex@Icepick.com (Alex)
Дата:
Сообщение: How to get last 10 rows in a table on a large database?
Следующее
От: Stoyan Genov
Дата:
Сообщение: Re: [SQL] pg_dump and "archive = none" ??