Re: Portal question

From: "Mitch Vincent" <mvincent(at)cablespeed(dot)com>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, "Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Portal question
Date: 2001-07-30 14:42:47
Message-ID: 002e01c11905$e70a7e40$1251000a@Mitch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I've used select count(), then a select LIMIT/OFFSET for the pages.. A
cursor might be a better idea though I don't think you can get the total
number of rows without count()'ing them.

Good luck!

-Mitch

----- Original Message -----
From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Hackers" <pgsql-hackers(at)postgresql(dot)org>
Sent: Monday, July 30, 2001 5:07 AM
Subject: [HACKERS] Portal question

> 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
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-07-30 14:43:04 Re: Re: From TODO, XML?
Previous Message jgray 2001-07-30 14:33:06 Re: From TODO, XML?