Re: [SQL] How to get last 10 rows in a table on a large database? - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] How to get last 10 rows in a table on a large database?
Date
Msg-id 2549.941912218@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] How to get last 10 rows in a table on a large database?  (Stoyan Genov <genov@digsys.bg>)
Responses Move forward all (Was Re: How to get last 10 rows in a table on a large database?)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] How to get last 10 rows in a table on a large database?
Next
From: Oleg Bartunov
Date:
Subject: Re: [SQL] How to get last 10 rows in a table on a large database?