From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Allan Kamau <kamauallan@gmail.com>
Cc: Postgres General Postgres General <pgsql-general@postgresql.org>
Subject: Re: GIN indexed unique constraint?
Date: Sun, 27 Jun 2021 14:41:09 -0400
Message-ID: <76947.1624819269@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwYZ1TgtN0KRxbFxJofDQub93ay9SmHPNV3t1rP45xGy1w@mail.gmail.com>
References: <CAF3N6oTcm+Dnf0R_XL+rDWw0PC_izgtfDtMQg1YzJQsEuU7M6w@mail.gmail.com>
<CAKFQuwYZ1TgtN0KRxbFxJofDQub93ay9SmHPNV3t1rP45xGy1w@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sun, Jun 27, 2021 at 11:18 AM Allan Kamau <kamauallan@gmail.com> wrote:
>> Is it possible to declare a UNIQUE constraint that uses GIN indexing?
> Doesn't seem to be possible. The btree_gin extension would provide the
> necessary code but it states explicitly that:
> "... and they lack one major feature of the standard B-tree code: the
> ability to enforce uniqueness."
GIN stores all the component elements of its input values separately.
It'd be tremendously hard even to identify which inputs share exactly
the same component elements; let alone whether inputs sharing the
same elements should be considered "equal". For example, ARRAY[1,2]
and ARRAY[2,1] would give rise to identical sets of index entries in
a GIN array_ops index.
In short, no, this isn't something you do with a GIN index.
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, david.g.johnston@gmail.com, kamauallan@gmail.com
Subject: Re: GIN indexed unique constraint?
In-Reply-To: <76947.1624819269@sss.pgh.pa.us>
References: <CAF3N6oTcm+Dnf0R_XL+rDWw0PC_izgtfDtMQg1YzJQsEuU7M6w@mail.gmail.com> <CAKFQuwYZ1TgtN0KRxbFxJofDQub93ay9SmHPNV3t1rP45xGy1w@mail.gmail.com> <76947.1624819269@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