Re: UUID v7
x4mmm@yandex-team.ru
From: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
To: Mat Arye <mat@timescaledb.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Tom Lane <tgl@sss.pgh.pa.us>,
Daniel Gustafsson <daniel@yesql.se>,
Matthias van de Meent <boekewurm+postgres@gmail.com>,
Nikolay Samokhvalov <samokhvalov@gmail.com>,
"Kyzer Davis (kydavis)" <kydavis@cisco.com>,
Andres Freund <andres@anarazel.de>,
Andrey Borodin <amborodin86@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>,
"brad@peabody.io" <brad@peabody.io>,
"wolakk@gmail.com" <wolakk@gmail.com>,
sergeyprokhorenko@yahoo.com.au
Date: 2023-08-31T18:51:35Z
Lists: pgsql-hackers
Thanks for interesting ideas, Mat! > On 31 Aug 2023, at 20:32, Mat Arye <mat@timescaledb.com> wrote: > > From a user perspective, it would be great to add 2 things: > - A function to extract the timestamp from a V7 UUID (very useful for defining constraints if partitioning by the uuid-embedded timestamps, for instance). Well, as far as I know, RFC discourages extracting timestamps from UUIDs. But we still can have such functions...maybe as an extension? > - Can we add an optional timestamptz argument to gen_uuid_v7 so that you can explicitly specify a time instead of always generating for the current time? If the argument is NULL, then use current time. This could be useful for backfilling and other applications. I think this makes sense. We could also have a counter as an argument. I'll try to implement that. However, so far I haven't figured out how to implement optional arguments for catalog functions. I'd appreciate any pointers here. Best regards, Andrey Borodin.
Commits
-
Fix timestamp overflow in UUIDv7 implementation.
- a5419bc72e22 18.0 landed
-
Add UUID version 7 generation function.
- 78c5e141e9c1 18.0 landed
-
Add some UUID support functions
- 794f10f6b920 17.0 landed