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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stoyan Genov <genov(at)digsys(dot)bg>
Cc: Alex(at)icepick(dot)com, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] How to get last 10 rows in a table on a large database?
Date: 1999-11-06 18:16:58
Message-ID: 2549.941912218@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stoyan Genov <genov(at)digsys(dot)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

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Bartunov 1999-11-06 19:09:48 Re: [SQL] How to get last 10 rows in a table on a large database?
Previous Message Tom Lane 1999-11-06 18:12:27 Re: [SQL] How to get last 10 rows in a table on a large database?