Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA82978 for ; Sat, 6 Nov 1999 13:18:43 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id NAA02551; Sat, 6 Nov 1999 13:16:59 -0500 (EST) To: Stoyan Genov cc: Alex@icepick.com, pgsql-sql@postgreSQL.org Subject: Re: [SQL] How to get last 10 rows in a table on a large database? In-reply-to: Your message of Sat, 06 Nov 1999 13:36:47 +0200 <199911061136.NAA00556@lorna.digsys.bg> Date: Sat, 06 Nov 1999 13:16:58 -0500 Message-ID: <2549.941912218@sss.pgh.pa.us> From: Tom Lane Stoyan Genov 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