Re: GSoC 2018 Project Ideas & Mentors - Last Call - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: GSoC 2018 Project Ideas & Mentors - Last Call
Date
Msg-id CAA4eK1KATC1TA5bR5eobYQVO3RWsnH6djNpk3P376em4V8MuUA@mail.gmail.com
Whole thread Raw
In response to Re: GSoC 2018 Project Ideas & Mentors - Last Call  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Jan 22, 2018 at 7:17 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Sun, Jan 21, 2018 at 9:02 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>> How about adding a project to support Unique capability for the Hash
>> Index?
>
> Hmm, that seems pretty hard.
>

Yeah, but I think here hard part is to decide the solution to achieve
it.   The problem is that for the hash index to ensure that there is
no duplicate entry we need to traverse the whole bucket chain and also
we need to ensure that only one backend should be allowed to perform
it.  The simplest way to ensure that is to take and retain an
exclusive lock on the primary bucket for the whole operation.  Now,
considering that for unique indexes there shouldn't be many overflows
buckets, retaining lock doesn't sound to be much problematic.  We can
even think of slightly different locking technique as well which is
that instead of always retaining the lock on the primary bucket, we
can keep the lock on the first bucket where we find the space to
insert the key and then proceed to find the entry again by taking an
exclusive lock on each overflow bucket one-by-one. Only one inserter
should win in this scheme, the others should find the entry inserted
by it and probably the concurrency won't also be bad.

-- 
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [HACKERS] MERGE SQL Statement for PG11
Next
From: David Steele
Date:
Subject: Re: PATCH: Configurable file mode mask