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

From Stephen Frost
Subject Re: UUID or auto-increment
Date
Msg-id 20200810171629.GW29590@tamriel.snowman.net
Whole thread Raw
In response to Re: UUID or auto-increment  (Israel Brewster <ijbrewster@alaska.edu>)
List pgsql-general
Greetings,

* Israel Brewster (ijbrewster@alaska.edu) wrote:
> > On Aug 10, 2020, at 8:53 AM, Stephen Frost <sfrost@snowman.net> wrote:
> > * Ron (ronljohnsonjr@gmail.com) wrote:
> >> On 8/10/20 11:38 AM, Ravi Krishna wrote:
> >>> Finally UUID results in write amplication in wal logs.  Keep that in mind
> >>> if your app does lot of writes.
> >>
> >> Because UUID is 32 bytes, while SERIAL is 4 bytes?
> >
> > and because it's random and so will touch a lot more pages when you're
> > using it...
>
> I would point out, however, that using a V1 UUID rather than a V4 can help with this as it is sequential, not random
(basedon MAC address and timestamp + random). There is a trade off, of course, as with V1 if two writes occur on the
samecomputer at the exact same millisecond, there is a very very small chance of generating conflicting UUID’s (see
https://www.sohamkamani.com/blog/2016/10/05/uuid1-vs-uuid4/
<https://www.sohamkamani.com/blog/2016/10/05/uuid1-vs-uuid4/>).As there is still a random component, however, this
seemsquite unlikely. 

Sure, that helps, but it's still not great, and they're still much, much
larger than you'd ever need for an identifier inside of a given system,
so best to map it to something reasonable and avoid them as much as
possible.

Thanks,

Stephen

Attachment

pgsql-general by date:

Previous
From: Israel Brewster
Date:
Subject: Re: UUID or auto-increment
Next
From: Adrian Klaver
Date:
Subject: Re: SQL Question about like