Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxc8N-0007Lz-6J for pgsql-general@arkaria.postgresql.org; Wed, 05 Sep 2018 18:02:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fxc8L-0007Wh-CM for pgsql-general@arkaria.postgresql.org; Wed, 05 Sep 2018 18:02:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxc8L-0007Wa-4C for pgsql-general@lists.postgresql.org; Wed, 05 Sep 2018 18:02:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fxc8I-0002mR-AC for pgsql-general@postgresql.org; Wed, 05 Sep 2018 18:02:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w85I2OrC001371; Wed, 5 Sep 2018 14:02:24 -0400 From: Tom Lane To: Paul Jungwirth cc: "pgsql-general@postgresql.org" Subject: Re: Full table lock dropping a foreign key In-reply-to: <5cfcdc5c-79db-98ed-6596-bc1fbae3ac10@illuminatedcomputing.com> References: <5cfcdc5c-79db-98ed-6596-bc1fbae3ac10@illuminatedcomputing.com> Comments: In-reply-to Paul Jungwirth message dated "Wed, 05 Sep 2018 09:35:27 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1369.1536170544.1@sss.pgh.pa.us> Date: Wed, 05 Sep 2018 14:02:24 -0400 Message-ID: <1370.1536170544@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Paul Jungwirth writes: > I noticed that Postgres takes an AccessExclusiveLock (a lock on the > whole table) against the *referenced* table when dropping a foreign key. Yeah, that's because it involves removing a trigger. Adding a trigger used to require AEL as well, but it was successfully argued that that end of things could use a weaker lock. I find the reasoning rather dubious myself. regards, tom lane