Re: UUID or auto-increment - Mailing list pgsql-general

From Israel Brewster
Subject Re: UUID or auto-increment
Date
Msg-id ED656DD2-64D2-4340-9933-D9951FF21CEB@alaska.edu
Whole thread Raw
In response to Re: UUID or auto-increment  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Responses Re: UUID or auto-increment  (John W Higgins <wishdev@gmail.com>)
List pgsql-general

> On Aug 10, 2020, at 12:06 PM, Peter J. Holzer <hjp-pgsql@hjp.at> wrote:
>
> On 2020-08-10 09:10:00 -0800, Israel Brewster wrote:
>> I would point out, however, that using a V1 UUID rather than a V4 can
>> help with this as it is sequential, not random (based on MAC address
>> and timestamp + random).
>
> If I read the specs correctly, a V1 UUID will roll over every 429
> seconds. I think that as far as index locality is concerned, this is
> essentially random for most applications.

According to wikipedia, the time value in a V1 UUID is a 60-bit number, and will roll over "around 3400AD”, depending
onthe algorithm used, or 5236AD if the software treats the timestamp as unsigned. This timestamp is extended by a 13 or
14-bit“uniqifying" clock sequence to handle cases of overlap, and then the 48bit MAC address (constant, so no rollover
there)is appended. So perhaps that 13 or 14 bit “uniqifying” sequence will roll over every 429 seconds, however the
timestamp*as a whole* won’t roll over for quite a while yet, thereby guaranteeing that the UUIDs will be sequential,
notrandom (since, last I checked, time was sequential). 

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory
Geophysical Institute - UAF
2156 Koyukuk Drive
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

>
>        hp
>
> --
>   _  | Peter J. Holzer    | Story must make more sense than reality.
> |_|_) |                    |
> | |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |       challenge!"




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Certficates
Next
From: Rob Sargent
Date:
Subject: Re: UUID or auto-increment