Re: GiST support for UUIDs

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: GiST support for UUIDs
Date: 2015-08-19 04:25:33
Message-ID: CA+renyUEE29=X01JXdz8_TQvo6n9=2XoEBBRnQ8rkLyr+kjPxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

This patch adds UUID support to the `btree_gist` extension. I've also
submitted it to the September commitfest (hopefully correctly!)

Many people are looking for this feature, e.g.:

http://dba.stackexchange.com/questions/83604/optimizing-postgres-row-overlap-constraints-involving-uuids-and-gist
http://stackoverflow.com/questions/22720130/how-to-use-uuid-with-postgresql-gist-index-type
http://www.postgresql.org/message-id/CAH3i69njJ9AX1fzHwt6uoUzCMBqnaDBwhmAPhRQzzLWifb2WOA@mail.gmail.com
http://www.postgresql.org/message-id/C59F2565-4753-4C83-BDCD-A0F9430B1638@datafax.com

As seen from those links, indexing UUIDs in a GiST is necessary when
including a UUID as part of an exclusion constraint. Here is my note
to the HACKERS list proposing this addition:

http://www.postgresql.org/message-id/CA+renyVepHxTO1c7dFbVjP1GYMUc0-3qDNWPN30-noo5MPyaVQ@mail.gmail.com

As discussed there, my changes are restricted to `contrib/btree_gist`.
I pretty much did a copy/paste of the code for intervals, since like
UUIDs they are 16 bytes. In some cases I could simplify, since
sometimes intervals can be less than 16 bytes, but not UUIDs.

This patch also includes tests and new files to bump the extension
version from 1.1 to 1.2.

One possible wart is that because the pg_uuid_t struct is defined in
uuid.c and hence invisible here, I had to repeat its definition (so
that I could include it in the GiST key struct). Alternately I could
move the definition in the core code into uuid.h, but my goal was to
touch only code in contrib. Let me know if you'd rather I made the
struct definition public and I can make that change.

This is my first patch, so my apologies if anything is missing. I went
the guidelines and I think I have everything covered. :-)

Thanks!
Paul Jungwirth

On Thu, Jun 25, 2015 at 9:50 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> writes:
>> On Thu, Jun 25, 2015 at 8:06 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> writes:
>>>> I'm interested in adding GiST support for the UUID column type
>>>> . . . . So I'm curious where this change would go?
>
>>> btree_gist, I'd think
>
>> Okay, thank you for your answer! I was worried about the effects of
>> having btree_gist depend on uuid-ossp. People won't have to say
>> `CREATE EXTENSION "uuid-ossp"` if they only want `btree_gist`, right?
>
> No, the uuid type exists in core. It's only some creation functions that
> are in that extension.
>
>>> the overhead of an extension version bump will probably
>>> exceed the useful payload :-(
>
>> Sorry to put more work on your plate. :-) I'm trying to pick something
>> easy to get my feet wet.
>
> That work will be on your plate actually ;-). Read the docs concerning
> creation of new extension versions, and perhaps look in our git history
> for previous commits that have upgraded contrib extensions.
>
> regards, tom lane

Attachment Content-Type Size
btree_gist_uuid_1.patch application/octet-stream 120.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-08-19 05:16:30 proposal: function parse_ident
Previous Message Kouhei Kaigai 2015-08-19 04:19:38 Re: Bug? ExecChooseHashTableSize() got assertion failed with crazy number of rows