Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8DF4D6328D1 for ; Tue, 22 Sep 2009 14:35:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 73114-10 for ; Tue, 22 Sep 2009 17:35:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 96DB96322F6 for ; Tue, 22 Sep 2009 14:35:42 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n8MHZd0x013527; Tue, 22 Sep 2009 13:35:39 -0400 (EDT) To: Bryce Nesbitt cc: pgsql-sql@postgresql.org Subject: Re: AccessExclusiveLock on CREATE TABLE REFERENCES deadlocks (formatted better) In-reply-to: <4AB90198.2010109@obviously.com> References: <4AB90198.2010109@obviously.com> Comments: In-reply-to Bryce Nesbitt message dated "Tue, 22 Sep 2009 09:55:52 -0700" Date: Tue, 22 Sep 2009 13:35:39 -0400 Message-ID: <13526.1253640939@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/107 X-Sequence-Number: 33172 Bryce Nesbitt writes: > 1) Why the AccessExclusiveLock on create table? It has to install a trigger on the referenced table. There has been some discussion that maybe CREATE TRIGGER could take just ExclusiveLock and not AccessExclusiveLock, but it hasn't been done yet; and I'm not sure how much that would help you anyway. It would only help if the referenced table (contexts) is essentially read-only to the rest of your workload, else it'll block anyhow. > 2) Why is the foreign key check a heavy operation, since a new table > will have zero foreign keys, it can't possibly violate the constraint yet. It's not a heavy operation in that case. The problem doubtless is that it's backed up behind some other transaction that is sitting on a lock on the contexts table. And then everything else backs up behind it. > 3) Other than eliminating dynamic table creation, how can this operation > be altered? Get rid of long-running transactions that hold locks on the contexts table. regards, tom lane