Portal question - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Portal question
Date
Msg-id ECEHIKNFIMMECLEBJFIGGEGKCBAA.chriskl@familyhealth.com.au
Whole thread Raw
List pgsql-hackers
Hi all,

This is the situation:  You are doing a big query, but you want the results
on the web page to be paginated.  ie. The user can click page 1, 2, etc.

So, you need know how many rows total would be returned, but you also only
need a small fraction of them.

What is an efficient way of doing this?

It seems to me that using a CURSOR would be advantageous, however once a
CURSOR is opened, how do you get the full row count?

ie. Can you do this:?

1. Declare a cursor
2. Find the total number of rows returned
3. Fetch the subset of the rows that are required
4. Construct a pagination based on the info from 2 and 3.

If this can't be done - how do you do it?  Is the only way to repeat the
whole query twice, the first time doing a count(*) instead of the select
variables?

Thanks,

Chris




pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: Re: From TODO, XML?
Next
From: Tatsuo Ishii
Date:
Subject: Re: PostgreSQL7.1 on AIX5L is running with too poor ferformance