Re: Pagination - 1 or 2 queries? - Mailing list pgsql-general

From scott.marlowe
Subject Re: Pagination - 1 or 2 queries?
Date
Msg-id Pine.LNX.4.33.0309051544510.31430-100000@css120.ihs.com
Whole thread Raw
In response to Re: Pagination - 1 or 2 queries?  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
On Fri, 5 Sep 2003, CSN wrote:

>
> --- "scott.marlowe" <scott.marlowe@ihs.com> wrote:
> > begin;
> > declare bubba as cursor for select * from table
> > order by fieldname;
> > move forward 100 in bubba;
> > fetch 5 from bubba;
> > rollback;
> >
> > Then you get the same kind of effect, but only 5
> > rows have to be retrieved
> > from the database to the client, and pg_fetch_array
> > will now iterate over
> > those 5 rows only, and then run dry, so to speak.
>
> Actually, with this method would you be able to get
> the count of all rows that could be returned (not just
> the 5)?

My previous one about using absolute count was wrong, btw, so you can
either fetch forward all and get the count that returns or run select
count(*).  note that if you fetch forward all on a complex query, you may
NOT be able to fetch backward all since cursors have a hard time going
backwards on complex queries.



pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Panic Index!!!!
Next
From: Tom Lane
Date:
Subject: Re: [PERFORM] Seq scan of table?