about cursors - Mailing list pgsql-general

From Ottavio Campana
Subject about cursors
Date
Msg-id 467416B3.1010601@campana.vi.it
Whole thread Raw
Responses Re: about cursors
Re: about cursors
List pgsql-general
I never used cursors before, and I'm trying to understand how to use
them well.

Postgresql doc says "a cursor that encapsulates the query, and then read
the query result a few rows at a time." So, when I open a cursor, is all
the query executed and results are returned a few a time?

My doubt comes from
http://archives.postgresql.org/pgsql-sql/2005-08/msg00230.php where I
read "when you open a cursor PostgreSQL doesn't know how many
rows it will return". So I start thinking that maybe it does not execute
the whole query....

At this point I'm not able to understand any more if cursor are useful
to reduce computational needs compared to running the same query each
time with limit and offset.

One last question: what happens to unclosed cursors? I mean, suppose an
application opens a cursor and crashes. What happens to that cursor? Is
there a way to close idle cursors?

Thanks.

--
Non c'e' piu' forza nella normalita', c'e' solo monotonia.


Attachment

pgsql-general by date:

Previous
From: PFC
Date:
Subject: Re: PHP sucks!! - was: persistent db connections in PHP
Next
From: "Joshua D. Drake"
Date:
Subject: Re: PHP sucks!! - was: persistent db connections in PHP