| From: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, theshallow27(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond |
| Date: | 2026-10-05 09:47:05 |
| Message-ID: | D90007B1-FFC1-4B8A-B20F-A2ED15615D8B@yandex-team.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On 4 Oct 2026, Tom Lane wrote:
> it's bandying around not two but three(!) different clock precisions,
The interval argument was intended to spread concurrent insert streams
over different index hot spots, keeping locality within each stream.
It shifts the generator's clock rather than taking an application
timestamp to encode. We discussed that distinction at some length
during development [0].
The precisions are deliberate: milliseconds for the UUID field,
microseconds for interval arithmetic, and finer clock precision for
the sub-millisecond bits. RFC 9562's Method 3 uses that extra precision
to reduce collisions [1], so we preserve the nanosecond remainder
across the interval calculation.
As for the original report, storing an arbitrary application timestamp
in a UUID is not the intended use. In our interpretation of the RFC,
these bits serve uniqueness and ordering, not timestamp storage. The
function deliberately uses its own clock, so
uuidv7(target - clock_timestamp()) does not promise to preserve the
exact microseconds of target.
Thank you!
Best regards, Andrey Borodin.
[0] https://www.postgresql.org/message-id/1012137874.340418.1721776188406@mail.yahoo.com
[1] https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-10-05 10:20:35 | Re: BUG #19628: Uninterruptible vacuum during hash index processing |
| Previous Message | Lele Gaifax | 2026-10-05 07:48:32 | Spurious curly bracket in "CREATE FUNCTION"/"CREATE PROCEDURE" doc |