Re: Strange Behavior with Serializable Transcations

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange Behavior with Serializable Transcations
Дата
Msg-id 19267.1151634422@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Strange Behavior with Serializable Transcations  ("Qingqing Zhou" <zhouqq@cs.toronto.edu>)
Список pgsql-general
"Qingqing Zhou" <zhouqq@cs.toronto.edu> writes:
> "Tom Lane" <tgl@sss.pgh.pa.us> wrote
>> Right, the snapshot does not become set until you do a non-utility
>> command (normally, SELECT/INSERT/UPDATE/DELETE).  This is a feature, not
>> a bug, because it lets the transaction take table locks before its
>> snapshot becomes set.

> Hm, mostly I understand it as an optimization. What do you mean by "it lets
> the transaction take table locks before its snapshot becomes set"?  If we
> take a snapshot at BEGIN, then the transaction can't take table locks?

It can, but there are cases where you want the lock to be taken before
the snapshot is set.  Otherwise, there could be committed changes in the
database that you can't see in your snapshot.  I think there are some
examples in the manual, or check the archives.

            regards, tom lane

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

Предыдущее
От: "Qingqing Zhou"
Дата:
Сообщение: Re: Strange Behavior with Serializable Transcations
Следующее
От: Chris
Дата:
Сообщение: Re: psql -h host ...