RE: [SQL] Move forward all (Was Re: How to get last 10 rows in a table on a large database?)

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Stoyan Genov" <genov(at)digsys(dot)bg>
Cc: <pgsql-sql(at)postgreSQL(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: RE: [SQL] Move forward all (Was Re: How to get last 10 rows in a table on a large database?)
Date: 1999-11-08 00:32:26
Message-ID: 000201bf2980$bb3c30e0$2801007e@cadzone.tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> -----Original Message-----
> From: owner-pgsql-sql(at)postgreSQL(dot)org [mailto:owner-pgsql-sql(at)postgreSQL(dot)
> org]On Behalf Of Stoyan Genov
> Sent: Sunday, November 07, 1999 7:25 PM
> To: Tom Lane
> Cc: pgsql-sql(at)postgreSQL(dot)org
> Subject: [SQL] Move forward all (Was Re: How to get last 10 rows in a
> table on a large database?)
>
>
> > > 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.
>
> Well, it does not seem to work for me neither on the 6.4.2 nor on the
> 6.5.(1|2)
> version. I'll try 6.5.3 as well...
> Any ideas why this is so?
>

Doesn't your query have any qualification(WHERE clause) about
columns in index ?
If there's no qualification,PostgreSQL optimizer chooses sequential
scan(however current developing tree probably chooses Index scan
in case of ORDER BY).
In case of Index scan,"fetch backward .." after "move forward all" is
possible after 6.5 ,
But in case of sequential scan,maybe it's still impossible.

I knew the way to fix it but am not sure now.
Do you really want to make it possible ?
It isn't an appropriate way to get last rows because "move forward
all" takes very long time.

Regards.

Hiroshi Inoue
Inoue(at)tpf(dot)co(dot)jp

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rich Shepard 1999-11-08 01:29:49 Specifying currency using a numeric data type
Previous Message Vince Gonzalez 1999-11-07 19:59:42 Re: [SQL] arrays of numeric?