pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Florian Weimer <fweimer@bfk.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: kakarukeys <kakarukeys@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: adding foreign key constraint locks up table
Date: Tue, 04 Jan 2011 13:52:24 +0000
Message-ID: <8239p8rd2f.fsf@mid.bfk.de> (raw)
In-Reply-To: <19238.1293548900@sss.pgh.pa.us>
References: <75218696-61be-4730-89f6-dd6058fa9eda@a28g2000prb.googlegroups.com>
	<82ei926j3p.fsf@mid.bfk.de>
	<19238.1293548900@sss.pgh.pa.us>

* 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@bfk.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



view thread (15+ messages)  latest in thread

Message-ID: <8239p8rd2f.fsf@mid.bfk.de>
Permalink:  ../8239p8rd2f.fsf@mid.bfk.de/
Also on:    postgresql.org/message-id/8239p8rd2f.fsf@mid.bfk.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: fweimer@bfk.de, tgl@sss.pgh.pa.us, kakarukeys@gmail.com
  Subject: Re: adding foreign key constraint locks up table
  In-Reply-To: <8239p8rd2f.fsf@mid.bfk.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox