Fwd: Sequence vs UUID

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Fwd: Sequence vs UUID
Date: 2023-02-03 15:58:40
Message-ID: CAFCRh-8EuCSZ=M91VN13gnixiHPPRWreWsRboCEL0d-TUsnjRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Copying the list...

---------- Forwarded message ---------
From: Dominique Devienne <ddevienne(at)gmail(dot)com>
Date: Fri, Feb 3, 2023 at 4:57 PM
Subject: Re: Sequence vs UUID
To: veem v <veema0000(at)gmail(dot)com>

On Thu, Feb 2, 2023 at 8:47 PM veem v <veema0000(at)gmail(dot)com> wrote:

> Tested the UUIDv7 generator for postgres as below.
> With regards to performance , It's still way behind the sequence. [...]
> explain analyze select count(nextval('myseq') ) from
> generate_series(1,100000);
> Execution Time: 59.687 ms
>
> explain analyze select count(gen_random_uuid()) from
> generate_series(1,100'000);
> Execution Time: 904.868 ms
>
> explain analyze select count(uuid_generate_v7()) from
> generate_series(1,100000);
> Execution Time: 1711.187 ms
>

Something's off regarding Guid generations IMHO...

You generate 100K Guids in ~1s. While we generate (in C++, Windows Release,
using Boost) 16M of them in +/- the same time:

Enabling Performance tests
>>>
>>

> generate 16'000'000 guids in 0.980s (user: 0.984s) 12 MB
>>>
>> generate 16'000'000 guids in parallel on 4 CPUs in 0.309s (user: 1.188s)
>>> 12 MB
>>>
>>
That's 2 orders of magnitude faster. Sure there's some overhead from the
SQL, but still. Something seems fishy.
And that's on a 2.5y old desktop. --DD

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message veem v 2023-02-03 16:47:57 Re: Sequence vs UUID
Previous Message Miles Elam 2023-02-03 15:35:05 Re: Sequence vs UUID