Re: UUID v1 optimizations... - Mailing list pgsql-performance

From Tom Lane
Subject Re: UUID v1 optimizations...
Date
Msg-id 21750.1558823888@sss.pgh.pa.us
Whole thread Raw
In response to Re: UUID v1 optimizations...  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: UUID v1 optimizations...
List pgsql-performance
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On Sat, May 25, 2019 at 05:54:15PM -0400, Tom Lane wrote:
>> What you might want to think about is creating a function that maps
>> UUIDs into an ordering that makes sense to you, and then creating
>> a unique index over that function instead of the raw UUIDs.  That
>> would give the results you want without having to negotiate with the
>> rest of the world about whether it's okay to change the semantics
>> of type uuid.

> FWIW that's essentially what I implemented as an extension some time
> ago. See [1] for a more detailed explanation and some benchmarks.

Also, another way to attack this is to create a new set of ordering
operators for UUID and an associated non-default btree opclass.
Then you declare your index using that opclass and you're done.
The key advantage of this way is that the regular UUID equality
operator can still be a member of that opclass, meaning that searches
of the form "uuidcol = constant" can still use this index, so you
don't have to change your queries (at least not for that common case).
Look at the interrelationship of the regular text btree operators and
the "pattern_ops" btree operators for a precedent.

            regards, tom lane



pgsql-performance by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: UUID v1 optimizations...
Next
From: Ancoron Luciferis
Date:
Subject: Re: UUID v1 optimizations...