Re: Pagination - 1 or 2 queries?

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Pagination - 1 or 2 queries?
Date: 2003-09-05 20:09:16
Message-ID: Pine.LNX.4.33.0309051407380.31114-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 5 Sep 2003, CSN wrote:

>
> --- "scott.marlowe" <scott(dot)marlowe(at)ihs(dot)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)?

Yes, you can use "fetch absolute count from cursorname" should work.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-09-05 20:20:55 Re: Pagination - 1 or 2 queries?
Previous Message Franco Bruno Borghesi 2003-09-05 19:56:54 C functions