Re: UUID or auto-increment

From: Israel Brewster <ijbrewster(at)alaska(dot)edu>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: UUID or auto-increment
Date: 2020-08-10 17:10:00
Message-ID: 6A5ADFD3-AF87-4DFF-AA71-5AC31ED94A07@alaska.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


---
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

> On Aug 10, 2020, at 8:53 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>
> Greeitngs,
>
> * Ron (ronljohnsonjr(at)gmail(dot)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 (based on MAC address and timestamp + random). There is a trade off, of course, as with V1 if two writes occur on the same computer 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 seems quite unlikely.

>
> Avoid UUIDs if you can- map them to something more sensible internally
> if you have to deal with them.
>
> Thanks,
>
> Stephen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2020-08-10 17:16:29 Re: UUID or auto-increment
Previous Message Michael Nolan 2020-08-10 17:01:08 Re: SQL Question about like