Re: Basic locking question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Basic locking question
Дата
Msg-id 21477.1126047992@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Basic locking question  (Ben <bench@silentmedia.com>)
Ответы Re: Basic locking question
Список pgsql-general
Ben <bench@silentmedia.com> writes:
> Doesn't select ... for update only lock the rows returned in the select?

Right.

> In my case, I'm worried about situations when no rows will be returned
> and two separate transactions will try to insert the same key.

Pretty much the only thing you can do about that is to take an exclusive
table-level lock.  This is simple but pretty awful for concurrency
(since the lock blocks everyone else from inserting ANY key, not only
the one you are inserting).

Consider using a sequence object to generate the keys, instead.

            regards, tom lane

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

Предыдущее
От: Ben
Дата:
Сообщение: Re: Basic locking question
Следующее
От: Ben
Дата:
Сообщение: Re: Basic locking question