pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: ALTER table taking ages...
Date: Fri, 27 Feb 2004 11:56:13 -0500
Message-ID: <20162.1077900973@sss.pgh.pa.us> (raw)
In-Reply-To: <403EF608.7040005@trade-india.com>
References: <403EF608.7040005@trade-india.com>

Rajesh Kumar Mallah <mallah@trade-india.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 h.pid as blocker, w.pid 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
doing.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <20162.1077900973@sss.pgh.pa.us>
Permalink:  ../20162.1077900973@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20162.1077900973@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mallah@trade-india.com
  Subject: Re: ALTER table taking ages...
  In-Reply-To: <20162.1077900973@sss.pgh.pa.us>
  References: <403EF608.7040005@trade-india.com> <20162.1077900973@sss.pgh.pa.us>

* 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