about cursors

Поиск
Список
Период
Сортировка
От Ottavio Campana
Тема about cursors
Дата
Msg-id 467416B3.1010601@campana.vi.it
обсуждение исходный текст
Ответы Re: about cursors  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: about cursors  (Martijn van Oosterhout <kleptog@svana.org>)
Список 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.


Вложения

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

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