Re: Could GetTransactionSnapshot be deferred till needed.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Could GetTransactionSnapshot be deferred till needed.
Дата
Msg-id 13447.1366865433@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Could GetTransactionSnapshot be deferred till needed.  (Daniel Wood <dwood@salesforce.com>)
Список pgsql-novice
Daniel Wood <dwood@salesforce.com> writes:
> Just as a permanent XID is allocate only when needed, is there any way
> to defer the acquisition of a snapshot till it is needed such that
> statements like "if x = 1 ..." and "x := 1" don't acquire snapshots just
> because they are in a non-read only function?  Could this be delayed
> till the start of any select/update/delete/insert, DDL, etc?

As noted in the comment there,

     * We have to do some of the things SPI_execute_plan would do, in
     * particular advance the snapshot if we are in a non-read-only function.
     * Without this, stable functions within the expression would fail to see
     * updates made so far by our own function.

You could possibly make such an optimization if you could be sure that
the expression being evaluated didn't examine database contents, or if
you knew that the current function hadn't yet changed anything.
The former seems a bit more practical --- you could check whether the
expression contains only immutable functions, which is a stronger test
than necessary but would probably admit most cases of practical
interest.

(This seems a bit out of scope for pgsql-novice, btw.)

            regards, tom lane


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

Предыдущее
От: Daniel Wood
Дата:
Сообщение: Could GetTransactionSnapshot be deferred till needed.
Следующее
От: i2013
Дата:
Сообщение: Re: How to Recover iPhone Contacts You Lost Somehow?