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 1q9AQe-000062-C4 for pgsql-general@arkaria.postgresql.org; Tue, 13 Jun 2023 20:15:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9AQd-00049w-6g for pgsql-general@arkaria.postgresql.org; Tue, 13 Jun 2023 20:15:47 +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 1q9AQc-00049W-SF for pgsql-general@lists.postgresql.org; Tue, 13 Jun 2023 20:15:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9AQa-002C81-Cc for pgsql-general@postgresql.org; Tue, 13 Jun 2023 20:15:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 35DKFftl1799077; Tue, 13 Jun 2023 16:15:42 -0400 From: Tom Lane To: =?UTF-8?Q?Torsten_F=C3=B6rtsch?= cc: PostgreSQL mailing lists Subject: Re: Exclusion constraint with negated operator? In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Torsten_F=C3=B6rtsch?= message dated "Tue, 13 Jun 2023 20:11:01 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1799075.1686687341.1@sss.pgh.pa.us> Date: Tue, 13 Jun 2023 16:15:41 -0400 Message-ID: <1799076.1686687341@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?Q?Torsten_F=C3=B6rtsch?= writes: > My question is can I somehow express something like > EXCLUDE (c1 WITH =, c2 with NOT =) > It seems that's not possible at the moment. But is there any obstacle in > principle or is it just not implemented? Well, it'd likely be a bad idea. Indexes are meant to help you quickly find a small part of a table that satisfies a condition. Finding the probably-much-larger part of the table that doesn't satisfy the condition is something they are bad at. This is why "=" is an indexable operator while "<>" is not. It's not impossible in principle for "<>" to be an index operator, but the set of cases where indexing on such a condition would beat a seqscan is likely to be uselessly small. By the same token, EXCLUDE constraints using such a condition would be unpleasantly inefficient. regards, tom lane