Re: Locking referenced table when creating and dropping tables with foreign key constraints

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Locking referenced table when creating and dropping tables with foreign key constraints
Дата
Msg-id 19744.1265069986@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Locking referenced table when creating and dropping tables with foreign key constraints  (frank joerdens <fiskadoro@gmail.com>)
Список pgsql-general
frank joerdens <fiskadoro@gmail.com> writes:
> It seems that whenever I create a new empty table with a foreign key
> constraint, the transaction will acquire an exclusive lock on the
> referenced table, locking out other writers (not sure if even readers
> as well), and I don't quite see why that is necessary

It involves an ALTER TABLE ADD TRIGGER command, which necessarily locks
out writers to avoid race conditions.  I think at the moment it may take
an exclusive lock and thereby lock out readers as well.  There has been
some talk of trying to reduce the lock strength needed for ALTER
operations, but you should not expect that it'll ever be possible to
do that without blocking writers.

            regards, tom lane

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

Предыдущее
От: "Hardwick, Joe"
Дата:
Сообщение: statement_timeout problem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: statement_timeout problem