Re: adding foreign key constraint locks up table

From: Florian Weimer
Subject: Re: adding foreign key constraint locks up table
Date: ,
Msg-id: 8239p8rd2f.fsf@mid.bfk.de
(view: Whole thread, Raw)
In response to: Re: adding foreign key constraint locks up table  (Tom Lane)
Responses: Re: adding foreign key constraint locks up table  (Tom Lane)
List: pgsql-performance

Tree view

adding foreign key constraint locks up table  (kakarukeys, )
 Re: adding foreign key constraint locks up table  (Gurjeet Singh, )
  Re: adding foreign key constraint locks up table  ("Kevin Grittner", )
   Re: adding foreign key constraint locks up table  (Gurjeet Singh, )
    Re: adding foreign key constraint locks up table  ("Kevin Grittner", )
 Re: adding foreign key constraint locks up table  (Lew, )
 Re: adding foreign key constraint locks up table  (kakarukeys, )
  Re: adding foreign key constraint locks up table  (Gurjeet Singh, )
 Re: adding foreign key constraint locks up table  (Florian Weimer, )
  Re: adding foreign key constraint locks up table  (Tom Lane, )
   Re: adding foreign key constraint locks up table  (Florian Weimer, )
    Re: adding foreign key constraint locks up table  (Tom Lane, )
 Re: adding foreign key constraint locks up table  (kakarukeys, )
  Re: adding foreign key constraint locks up table  (Robert Haas, )
 Re: adding foreign key constraint locks up table  (kakarukeys, )

* 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                <>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99


pgsql-performance by date:

From: Ben Chobot
Date:
Subject: Re: Question: BlockSize > 8192 with FusionIO
From: "Strange, John W"
Date:
Subject: Re: Question: BlockSize > 8192 with FusionIO