Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 3B38D63255A for ; Wed, 22 Apr 2009 04:16:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 68866-03 for ; Wed, 22 Apr 2009 04:16:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by mail.postgresql.org (Postfix) with ESMTP id 2DBEC6321F1 for ; Wed, 22 Apr 2009 04:16:14 -0300 (ADT) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1LwWgm-0002QN-Gh for pgsql-performance@postgresql.org; Wed, 22 Apr 2009 00:16:12 -0700 Message-ID: <23170924.post@talk.nabble.com> Date: Wed, 22 Apr 2009 00:16:12 -0700 (PDT) From: roopabenzer To: pgsql-performance@postgresql.org Subject: Re: probelm with alter table add constraint...... In-Reply-To: <27085.1239026040@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: roopabenzer@gmail.com References: <5da3d2700904052354g61f02031x822322e9ee512ad9@mail.gmail.com> <27085.1239026040@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/349 X-Sequence-Number: 33716 Tom Lane-2 wrote: > > "Albe Laurenz" writes: >> roopasatish wrote: >>> I have an issue with the add foreign key constraint which >>> goes for waiting and locks other queries as well. >>> >>> ALTER TABLE ONLY holding_positions ADD CONSTRAINT >>> holding_positions_stock_id_fkey FOREIGN KEY (stock_id) >>> REFERENCES stocks (stock_id) MATCH SIMPLE >>> ON UPDATE NO ACTION ON DELETE NO ACTION; >>> >>> The holding_positions table has no data in it as yet. > >> Look in pg_catalog.pg_locks for a second transaction that >> holds a lock on the table holding_positions. > > This statement also needs to get lock on the referenced table "stocks". > An open transaction that's referenced either table will block it. > > regards, tom lane > > -- > Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-performance > > I can't lock the table 'stocks' as its used continuously by many users. Is there a way to run the constraint in a background without affecting the users using the database. Thanks a lot in advance Roopa -- View this message in context: http://www.nabble.com/probelm-with-alter-table-add-constraint......-tp22903334p23170924.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com.