Search Postgresql Archives

Re: about cursors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ottavio Campana <ottavio@xxxxxxxxxxxxx> writes:
> 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

No, just enough to give you the rows you ask for.  Otherwise the query
state is held open until the next FETCH.

Exception: if you declare a cursor WITH HOLD then it's executed to
completion before the transaction commits, because the resources
involved in an open query (eg locks) can't be kept across transactions.

Also, depending on how complex the query is, the system might have to do
most of the work before it can deliver even the first row.  ORDER BY
implemented by an explicit sort step is like that, for example.

			regards, tom lane


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux