On Mon, 28 Aug 2000, Paula Greve wrote:
> Sorry for the very trivial and probably obvious question -- but I have
> looked all over the documentation and have been unable to find a discussion
> on this.
> When do I want to declare and use a cursor -- and why?
You want to use a cursor when you have a query that (potentially) returns a
large number of rows, so many, that it might exhaust memory if returned all at
The cursor allows you to submit the query and then retrieve one or more of the
result rows/tuples at a time, which keeps memory usage low. You can move
forward and backward in the results to retrieve the same rows many times if you
need to without having to query again.
A cursor is also useful if you want to return information in pages at a time
for some application. You can move forward by x-per-page * pagenumber, to
retrieve the page wanted from the results. You have to include a SORT BY
in the query that is used to create the cursor to get pages in a meaningful
Hope this helps a little. I might be able to come up with some examples if you
can't find any.
-------- Robert B. Easter reaster(at)comptechnews(dot)com ---------
- CompTechNews Message Board http://www.comptechnews.com/ -
- CompTechServ Tech Services http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------
In response to
pgsql-novice by date
|Next:||From: S.A.Pamungkas||Date: 2000-08-29 03:44:19|
|Subject: destroying db / closing access|
|Previous:||From: Brian D. Woodruff||Date: 2000-08-28 18:32:52|
|Subject: Re: backend closed|