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

Re: ALTER table taking ages...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: ALTER table taking ages...
Date: 2004-02-27 16:56:13
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
Rajesh Kumar Mallah <mallah(at)trade-india(dot)com> writes:
> It takes ages to drop a constraint from one of my tables
> [ table details at the end ] I cannot insert into it also.

DROP CONSTRAINT in itself isn't going to take any significant amount of
time.  The only plausible explanation is that some other session has a
lock on the table, forcing the DROP to wait.  DROP is going to want
access-exclusive lock on the table, so pretty much anything will block it.

> tradein_clients=# SELECT * from pg_locks where mode='ExclusiveLock' and 
> granted is true;

This is unhelpful.  In the first place there are multiple kinds of lock
and you've shown only one.  In the second place, the entries you want to
start from are the ones with granted not true, because that indicates
someone waiting for a lock.  Try something like

select as blocker, as blockee from pg_locks h, pg_locks w
where h.granted and not w.granted and
  ((h.relation = w.relation and h.database = w.database) or
   h.transaction = w.transaction);

and then look in pg_stat_activity to find out what each process is

			regards, tom lane

In response to


pgsql-admin by date

Next:From: Phillip R. aka QbertDate: 2004-02-27 17:13:58
Subject: Solution! (was: Re: Linux (Debian Woody)...)
Previous:From: John AllgoodDate: 2004-02-27 16:11:06
Subject: Re: Running Multiple Postmasters

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