LiosK / uuid7-rs

A Rust implementation of UUID version 7
Apache License 2.0
31 stars 0 forks source link

Performance #1

Closed AppyCat closed 2 years ago

AppyCat commented 2 years ago

Thank you for your work on this library.

Would you have any feedback on the performance difference in Postgres DB for primary key on a table with 1 million records for read, write sorting between:

BIGINT UUID v7 ULID

LiosK commented 2 years ago

I have no idea about Postgres' implementation, but I don't see a plausible reason why the read/sort performance differs between UUIDv7 and ULID as long as they are stored in the 128-bit binary form because the proposed UUIDv7 produces a quite similar byte sequence to ULID.

As for the write performance, UUIDv7 and ULID have several flavors in monotonicity guarantee, and the performance characteristics vary depending on the throughput of random number generator and the cost of mutex and other synchronization mechanisms. But if you only need one million records, then such a difference will be negligible (unless you wish to generate one million IDs every second).