pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stoyan Genov <genov@digsys.bg>
To: Hiroshi Inoue <Inoue@tpf.co.jp>
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Move forward all (Was Re: How to get last 10 rows in a table on a large database?)
Date: Mon, 08 Nov 1999 11:27:07 +0200
Message-ID: <199911080927.LAA03731@lorna.digsys.bg> (raw)
In-Reply-To: <000201bf2980$bb3c30e0$2801007e@cadzone.tpf.co.jp>

> > -----Original Message-----
> > From: owner-pgsql-sql@postgreSQL.org [mailto:owner-pgsql-sql@postgreSQL.
> > org]On Behalf Of Stoyan Genov
> > Sent: Sunday, November 07, 1999 7:25 PM
> > To: Tom Lane
> > Cc: pgsql-sql@postgreSQL.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 have tested this - for a sequental scan it is still impossible (talking
6.4.2 and 6.5.* versions)

> 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.
> 


Of course it is not an appropriate way to get the last rows like this.
The "right" way IMHO is to reverse the order in the query and to get the 
first
rows. 

It is just for the sake of truth...

> Regards.
> 
> Hiroshi Inoue
> Inoue@tpf.co.jp


Regards,
 
Stoyan Genov




view thread (6+ messages)  latest in thread

Message-ID: <199911080927.LAA03731@lorna.digsys.bg>
Permalink:  ../199911080927.LAA03731@lorna.digsys.bg/
Also on:    postgresql.org/message-id/199911080927.LAA03731@lorna.digsys.bg

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: genov@digsys.bg, Inoue@tpf.co.jp
  Subject: Re: [SQL] Move forward all (Was Re: How to get last 10 rows in a table on a large database?)
  In-Reply-To: <199911080927.LAA03731@lorna.digsys.bg>
  References: <000201bf2980$bb3c30e0$2801007e@cadzone.tpf.co.jp> <199911080927.LAA03731@lorna.digsys.bg>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox