Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0COH-0005Ot-8W for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Nov 2022 02:00:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p0COF-0005Pf-Et for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Nov 2022 01:59:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0COF-0005PW-5M for pgsql-hackers@lists.postgresql.org; Wed, 30 Nov 2022 01:59:59 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0COC-0001lx-O9 for pgsql-hackers@lists.postgresql.org; Wed, 30 Nov 2022 01:59:58 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1p0CO5-004cFb-PP; Tue, 29 Nov 2022 20:59:49 -0500 Date: Tue, 29 Nov 2022 20:59:49 -0500 From: Bruce Momjian To: Tom Lane Cc: Greg Stark , David Zhang , Simon Riggs , Cary Huang , Pgsql Hackers Subject: Re: Patch: Global Unique Index Message-ID: References: <184879c5306.12490ea581628934.7312528450011769010@highgo.ca> <46a0f6fb-1c0b-bbd8-ef3e-366216a89501@highgo.ca> <1239139.1669763636@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1239139.1669763636@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Nov 29, 2022 at 06:13:56PM -0500, Tom Lane wrote: > Greg Stark writes: > > If I understand correctly you're going to insert into the local index > > for the partition using the normal btree uniqueness implementation. > > Then while holding an exclusive lock on the index do lookups on every > > partition for the new key. Effectively serializing inserts to the > > table? > > ... not to mention creating a high probability of deadlocks between > concurrent insertions to different partitions. If they each > ex-lock their own partition's index before starting to look into > other partitions' indexes, it seems like a certainty that such > cases would fail. The rule of thumb about locking multiple objects > is that all comers had better do it in the same order, and this > isn't doing that. I am not sure why they would need to exclusive lock anything more than the unique index entry they are adding, just like UPDATE does. > I still think this is a dead end that will never get committed. > If folks want to put time into perhaps finding an ingenious > way around these problems, okay; but they'd better realize that > there's a high probability of failure, or at least coming out > with something nobody will want to use. Agreed, my earlier point was that this would need a lot of thought to get right since we don't do this often. The exclusion constraint is a close example, though that is in a single index. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Embrace your flaws. They make you human, rather than perfect, which you will never be.