Skip site navigation (1) Skip section navigation (2)

Re: adding foreign key constraint locks up table

From: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
To: kakarukeys <kakarukeys(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: adding foreign key constraint locks up table
Date: 2010-12-28 15:01:24
Message-ID: AANLkTim4FYX-DcFhwQVBQ_BmsO_xsKVeJP7p1XTL4h=R@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Tue, Dec 28, 2010 at 8:55 AM, kakarukeys <kakarukeys(at)gmail(dot)com> wrote:

>
> > How long did you wait?
> hours in the past.
> For recent happenings, I aborted after 10 mins.
>
> Since it's a new table's creation, 'bbb' is empty.
> The 'alter table' never finished, so the lock was not released.
> aaa.id, bbb.topic_id are integers (id is auto-increament key)
>

That surely is a _long_ time for an empty table's ALTER.


>
>
> I also saw this:
>
> http://postgresql.1045698.n5.nabble.com/Update-INSERT-RULE-while-running-for-Partitioning-td2057708.html
>
> "Note that using ALTER TABLE to add a constraint as well as
> using DROP TABLE or TRUNCATE to remove/recycle partitions are
> DDL commands that require exclusive locks.  This will block
> both readers and writers to the table(s) and can also cause readers
> and writers to now interfere with each other. "
>
>
In your case ALTER TABLE would lock bbb, but not aaa; other sessions should
still be able to read aaa.

Regards,
-- 
gurjeet.singh
@ EnterpriseDB - The Enterprise Postgres Company
http://www.EnterpriseDB.com

singh(dot)gurjeet(at){ gmail | yahoo }.com
Twitter/Skype: singh_gurjeet

Mail sent from my BlackLaptop device

In response to

pgsql-performance by date

Next:From: Kevin GrittnerDate: 2010-12-28 15:07:33
Subject: Re: adding foreign key constraint locks up table
Previous:From: Florian WeimerDate: 2010-12-28 14:57:14
Subject: Re: adding foreign key constraint locks up table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group