Re: postgresql locks the whole table!

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: postgresql locks the whole table!
Дата
Msg-id 874qwh7rjo.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на postgresql locks the whole table!  (Dr NoName <spamacct11@yahoo.com>)
Ответы Re: postgresql locks the whole table!
Список pgsql-general
Dr NoName <spamacct11@yahoo.com> writes:

> My question is why??? The two insert operations do not
> conflict with each other (at least not in the
> real-world situation). Also, why does the foreign key
> make a difference?

It's not locking the whole table, it's locking the record that the foreign key
references. Note that they're both referencing the same foreign key.

It does this because it's afraid someone will go and delete that key before
the transaction commits. It has to take a lock that will prevent someone from
deleting the record (or updating the referenced column).

Unfortunately the only lock to choose from is an exclusive write lock. That's
overkill as you've noticed. I think this is something multiple people would
like to fix by introducing shared locks, but I wouldn't expect a solution
soon.

I don't know if there's any work-around better than just dropping the foreign
key reference.

--
greg

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

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: C Programming with postgres.h - my function crashes
Следующее
От: Bopolissimus Platypus
Дата:
Сообщение: Any *current* summary of postgres-r 7.2 status? (was Re: Feature Request for 7.5)