Re: UUID v7

From: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>
To: Mat Arye <mat(at)timescaledb(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, "Kyzer Davis (kydavis)" <kydavis(at)cisco(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Andrey Borodin <amborodin86(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, "brad(at)peabody(dot)io" <brad(at)peabody(dot)io>, "wolakk(at)gmail(dot)com" <wolakk(at)gmail(dot)com>, sergeyprokhorenko(at)yahoo(dot)com(dot)au
Subject: Re: UUID v7
Date: 2023-08-31 18:51:35
Message-ID: C80B8FDB-8D9E-48A2-82A2-48863987A1B1@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for interesting ideas, Mat!

> On 31 Aug 2023, at 20:32, Mat Arye <mat(at)timescaledb(dot)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.

In response to

Responses

  • Re: UUID v7 at 2023-10-09 10:15:45 from Chris Travers
  • Re: UUID v7 at 2023-10-09 16:46:17 from Nick Babadzhanian

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2023-08-31 19:25:09 Suppressing compiler warning on Debian 12/gcc 12.2.0
Previous Message Pavel Stehule 2023-08-31 18:50:02 Re: Schema variables - new implementation for Postgres 15