Re: adding foreign key constraint locks up table

From: Florian Weimer <fweimer(at)bfk(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: kakarukeys <kakarukeys(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: adding foreign key constraint locks up table
Date: 2011-01-04 13:52:24
Message-ID: 8239p8rd2f.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

* Tom Lane:

>> Do you mean that the ALTER query and subsequent queries are shown as
>> "waiting" in pg_stat_activity? In this case, I'm also wondering why
>> this is inecessary.
>
> ALTER ADD FOREIGN KEY must lock both tables to add triggers to them.

But why is such a broad lock needed? If the table was created in the
current transaction and is empty, the contents of the foreign key
table should not matter.

--
Florian Weimer <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Greg Smith 2011-01-04 13:53:01 Re: concurrent IO in postgres?
Previous Message Greg Smith 2011-01-04 02:28:31 Re: Performance of PostgreSQL over NFS