Re: about cursors

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: about cursors
Дата
Msg-id 12401.1182014645@sss.pgh.pa.us
обсуждение исходный текст
Ответ на about cursors  (Ottavio Campana <ottavio@campana.vi.it>)
Список pgsql-general
Ottavio Campana <ottavio@campana.vi.it> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: PHP sucks!! - was: persistent db connections in PHP
Следующее
От: Tom Allison
Дата:
Сообщение: Re: Using the GPU