Re: UUID v7

From: Sergey Prokhorenko <sergeyprokhorenko(at)yahoo(dot)com(dot)au>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>, Przemysław Sztoch <przemyslaw(at)sztoch(dot)pl>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mat Arye <mat(at)timescaledb(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, Junwang Zhao <zhjwpku(at)gmail(dot)com>
Subject: Re: UUID v7
Date: 2024-03-22 11:43:58
Message-ID: 116297522.162005.1711107838411@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I think it's better to leave Andrey's patch as is, and add another function in the future with a customizable UUIDv7 structure for special use cases. The structure description can be in JSON format. See this discussion.

Sergey Prokhorenko sergeyprokhorenko(at)yahoo(dot)com(dot)au

On Friday, 22 March 2024 at 09:54:07 am GMT+3, Andrey M. Borodin <x4mmm(at)yandex-team(dot)ru> wrote:

> On 21 Mar 2024, at 20:21, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:
>
> On Wed, 20 Mar 2024 at 19:08, Andrey M. Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>> Timer-based bits contribute to global sortability. But the real timers we have are not even millisecond adjusted. We can hope for ~few ms variation in one datacenter or in presence of atomic clocks.
>
> I think the main benefit of using microseconds would not be
> sortability between servers, but sortability between backends.

Oh, that’s an interesting practical feature!
Se, essentially counter is a theoretical guaranty of sortability in one backend, while microseconds are practical sortability between backends.

> However, I don't really think it is incredibly important to get the
> "perfect" approach to filling in rand_a/rand_b right now. As long as
> we don't document what we do, we can choose to change the method
> without breaking backwards compatibility. Because either approach
> results in valid UUIDv7s.

Makes sense to me. I think both methods would be much better than UUIDv4 for practical reasons. And even not using extra bits at all (fill them with random numbers) would work for 0.999 cases.

Best regards, Andrey Borodin.

In response to

  • Re: UUID v7 at 2024-03-22 06:53:51 from Andrey M. Borodin

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-03-22 12:00:07 Re: Introduce XID age and inactive timeout based replication slot invalidation
Previous Message Viliam Ďurina 2024-03-22 11:26:27 MIN/MAX functions for a record