Re: Sequential UUID Generation - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: Sequential UUID Generation
Date
Msg-id b6bff056-39aa-cd18-b2a8-9ca4e08a1bfb@2ndquadrant.com
Whole thread Raw
In response to Sequential UUID Generation  (Uday Bhaskar V <uday.bhaskar579@gmail.com>)
Responses Re: Sequential UUID Generation  (Uday Bhaskar V <uday.bhaskar579@gmail.com>)
List pgsql-hackers
I don't think PostgreSQL has anything like that at the moment. It would
not be difficult to tweak the UUID generator to generate sequential (or
monotonic) values, the tricky part seems to be durability requirements.

One idea would be to simply store the value in (shared) memory, but that
would mean losing the state on restart/crash, so there would need to be
some sort of protection against generating duplicate values (say, using
postmaster timestamp as the first 64 bits of the UUID).

Another idea is to piggy-back this on bigint sequence somehow - split
the 128bit range into 64+64, use the sequence value for the first 64b
and pick the other half by random. That would guarantee both uniqueness,
monotonicity and durability. And it would also be fairly random, making
it difficult to guess UUIDs.

regards

On 10/29/2018 04:06 PM, Uday Bhaskar V wrote:
> Hi,
> 
>  We have migrated from Oracle to Postgres, there because of the
> replication requirements we used UUID columns.
> I did a POC(in postgres) with sequential UUID against Non sequential
> which has shown lot of different in space utilization and index size.
> Sql server has "newsequentialid" which generates sequential UUID.  I
> need similar functionality here. 
> I want to create a function which generates a sequential UUIDs, Any
> suggestions or support would be much appreciated.   
> 
> Thanks,
> Uday

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: pgbench doc fix
Next
From: Uday Bhaskar V
Date:
Subject: Re: Sequential UUID Generation