> On 20 Aug 2023, at 23:56, Andrey M. Borodin <x4...@yandex-team.ru> wrote: > > <v4-0001-Implement-UUID-v7-as-per-IETF-draft.patch>
I've observed, that pre-generating and buffering random numbers makes UUID generation 10 times faster. Without buffering postgres=# with x as (select gen_uuid_v7() from generate_series(1,1e6)) select count(*) from x; Time: 5286.572 ms (00:05.287) With buffering postgres=# with x as (select gen_uuid_v7() from generate_series(1,1e6)) select count(*) from x; Time: 390.091 ms This can speed up gen_random_uuid() on the same scale too. PFA implementation of this technique. Best regards, Andrey Borodin.
v5-0001-Implement-UUID-v7-as-per-IETF-draft.patch
Description: Binary data
v5-0002-Buffer-random-numbers.patch
Description: Binary data
v5-0003-Use-cached-random-numbers-in-gen_random_uuid-too.patch
Description: Binary data