From: | Erik Nordström <erik(at)tigerdata(dot)com> |
---|---|
To: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Fix for typo in UUIDv7 timestamp extraction |
Date: | 2025-08-13 12:53:43 |
Message-ID: | CACAa4VLbHON2dVLhTzzzO_2vjFf1DuXEdnCts=+dpNihWjge0g@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Aug 13, 2025 at 11:52 AM Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
wrote:
> Hi Erik!
>
> > On 13 Aug 2025, at 11:05, Erik Nordström <erik(at)tigerdata(dot)com> wrote:
> >
> > I think I found a small typo in the function that extracts a timestamp
> from a UUIDv7 (uuid_extract_timestamp). Unless I am mistaken, the constant
> US_PER_MS should be used instead of NS_PER_US when converting milliseconds
> to microseconds. Fortunately, these constants are the same so the
> calculation is still correct.
>
> Wow, that's a very good level of proofreading! Yes, you are correct, it's
> must be US_PER_MS.
>
> >
> > Anyway, attaching a patch to fix this typo.
>
> LGTM.
>
Ok, maybe a committer would like to commit this change immediately?
>
>
> >
> > On a related note, I am wondering why this function doesn't extract and
> use the sub-millisecond information in the rand_a bits? These bits are
> added when generating the UUID, but they don't seem to be extracted.
> Hopefully somebody could shed some light on this and whether it would be a
> worthwhile addition.
>
> UUID might be formed by any external system, rand_a bits are not
> guaranteed to be non-random. Well, in some sense, reading time is reading
> random number, but anyway, we don't know for sure how those bits are used.
> And even in Postgres usage of sub-millisecond fractions depends on OS.
>
> I think we can have a function in an extensions, that does pretend that
> UUID was generated by known algorithm. Or even SQL function to extract
> microseconds.
>
>
That's what I suspected. Thanks for clarifying.
Best,
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | Nazir Bilal Yavuz | 2025-08-13 13:25:27 | Re: meson vs. llvm bitcode files |
Previous Message | Ashutosh Bapat | 2025-08-13 12:39:47 | Report reorder buffer size |