From: Tom Lane <tgl@sss.pgh.pa.us>
To: Torsten Förtsch <tfoertsch123@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: Exclusion constraint with negated operator?
Date: Tue, 13 Jun 2023 16:15:41 -0400
Message-ID: <1799076.1686687341@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKkG4_=4Wo43KfFNE1i_91p+xJnGry_WM8fngH8Tv=F5wBD=wA@mail.gmail.com>
References: <CAKkG4_=4Wo43KfFNE1i_91p+xJnGry_WM8fngH8Tv=F5wBD=wA@mail.gmail.com>
=?UTF-8?Q?Torsten_F=C3=B6rtsch?= <tfoertsch123@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, tfoertsch123@gmail.com
Subject: Re: Exclusion constraint with negated operator?
In-Reply-To: <1799076.1686687341@sss.pgh.pa.us>
References: <CAKkG4_=4Wo43KfFNE1i_91p+xJnGry_WM8fngH8Tv=F5wBD=wA@mail.gmail.com> <1799076.1686687341@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox