Re: number of rown in a cursor. - Mailing list pgsql-general

From John DeSoi
Subject Re: number of rown in a cursor.
Date
Msg-id 52BAB200-6E40-11D9-A056-000A95B03262@pgedit.com
Whole thread Raw
In response to Re: number of rown in a cursor.  (Christoffer Gurell <orbit@0x63.nu>)
List pgsql-general
On Jan 24, 2005, at 1:38 PM, Christoffer Gurell wrote:

> the thing is that i want to create a gui-widget that has the
> possibility
> to show a large amount of data over a slow connection. My idea was that
> i create a cursor and create a srollbar with the number of rows in the
> cursor so the user can scroll and only fetch the rows displayed from
> the
> cursor as the user releases the scrollbar.
>
> If i understand right then the way to do this is: create the cursor,
> move to the end to get the number of rows, move to the front. get data.
> am i right? or is there a better way to achieve this ? perhaps with a
> local view?


Yes, you are correct -- see long discussions in the archives on
count(*). There is no shortcut to determine the number of rows a query
(or cursor) will have. One option might be to set some fairly high
limit in your query (say 10,000) and then have your GUI include some
little warning if it is reached. Perhaps have an easy way to increase
it if user really wants to scroll more records. It is definitely a bit
messy to deal with this in a GUI, but scrolling a million records won't
be very useful anyway.

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


pgsql-general by date:

Previous
From: Vincenzo Ciancia
Date:
Subject: Validating user-input to be inserted in regular expressions
Next
From: Tom Lane
Date:
Subject: Re: [7.4.1] signal 11 while accesing DB