Re: number of rown in a cursor.

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Christoffer Gurell <orbit(at)0x63(dot)nu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: number of rown in a cursor.
Date: 2005-01-24 19:44:12
Message-ID: 52BAB200-6E40-11D9-A056-000A95B03262@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-01-24 19:48:51 Re: [7.4.1] signal 11 while accesing DB
Previous Message Gregory Stark 2005-01-24 19:05:15 Bug report in 7.4