Skip to content

Switch to UUIDv7 for client-side GUID generation #2909

@tparvi

Description

@tparvi

In the past there have been few issues related to guid generation:

The issue #105 says We're dropping sequential Guid generation because PostgreSQL doesn't do clustered indices

The issue #2414 is closed because there really wasn't any proof/documentation provided that using sequential guids is beneficial

I ran into the following article that compared random uuids vs sequential and found an issue with random uuids:
https://www.cybertec-postgresql.com/en/unexpected-downsides-of-uuid-keys-in-postgresql/

I guess my question has multiple parts

a) Does that article have any merit? I am not postgres expert so I have no way of knowing is this is a real issue or can I just keep using Guid.NewGuid()
b) We are using Guid as primary key and generating it with Guid.NewGuid. There is also this GuidValueGenerator but documentation says it can only be used to generate non key values: https://www.npgsql.org/efcore/modeling/generated-properties.html?tabs=13%2Cefcore5#guiduuid-generation Is there a way to use that value generator directly like var id = GuidValueGenerator().Generate(). We need to generate the id client side.
c) If sequential uuids would be beneficial are there any recommendations on how to generate them? There are of course loads of libraries that can generate e.g. v7 uuid like https://github.com/mareek/UUIDNext

Metadata

Metadata

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions