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

Поиск
Список
Период
Сортировка
От frank joerdens
Тема Locking referenced table when creating and dropping tables with foreign key constraints
Дата
Msg-id 7d10d2df1002011222g527b24b9v31aba586321c47ee@mail.gmail.com
обсуждение исходный текст
Ответы Re: Locking referenced table when creating and dropping tables with foreign key constraints  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
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 if the new
entity does not contain any rows since there is nothing to check or
validate in terms of the presence of values in the referenced column.

This is biting us particularly now (it took the site down for a few
minutes each time for the last couple of days) because we have a
number of tables, and intend to add more, that are partitioned by
date, all of which reference the core "person" table, for which we
make new partitions daily via cron, and there is just no way we can
take the app offline each time. And we will also soon start dropping
them (i.e. removing from the inheritance hierarchy, archiving the
content and then dropping them) automatically on an ongoing basis to
keep the core data set manageable.

In fact, it even looks like the dropping also requires a lock on the
referenced table which makes even less sense to me ...

Am I confused, or is there a way around it? We are on 8.3.7 atm.

Regards,

Frank

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

Предыдущее
От: "Igor Neyman"
Дата:
Сообщение: Re: combine SQL SELECT statements into one
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: combine SQL SELECT statements into one