Re: Question about the holdable cursor

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Question about the holdable cursor
Дата
Msg-id 31845.1555596593@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Question about the holdable cursor  (Andy Fan <zhihui.fan1213@gmail.com>)
Ответы Re: Question about the holdable cursor  (Andy Fan <zhihui.fan1213@gmail.com>)
Список pgsql-hackers
Andy Fan <zhihui.fan1213@gmail.com> writes:
> when I fetch from holdable cursor,  I found the fact is more complex than I
> expected.
> ...
> why the 3rd time is necessary and will the performance be bad due to this
> design?

If you read the whole cursor output, then close the transaction and
persist the cursor, yes we'll read it twice, and yes it's bad for that
case.  The design is intended to perform well in these other cases:

1. The HOLD option isn't really being used, ie you just read and
close the cursor within the original transaction.  This is important
because applications are frequently sloppy about marking cursors as
WITH HOLD.

2. You declare the cursor and persist it before reading anything from it.
(This is really the typical use-case for held cursors, IMV.)

FWIW, I don't see any intermediate tuplestore in there when
dealing with a PORTAL_ONE_SELECT query, which is the only
case that's possible with a cursor no?

            regards, tom lane



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: proposal: psql PSQL_TABULAR_PAGER variable
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Race conditions with checkpointer and shutdown