pg_idkit
postgresql-uuid-generate-v7 | pg_idkit | |
---|---|---|
1 | 8 | |
25 | 312 | |
- | 6.4% | |
2.8 | 8.6 | |
10 months ago | 2 months ago | |
PLpgSQL | Rust | |
MIT License | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
postgresql-uuid-generate-v7
-
Bye Sequence, Hello UUIDv7
If it helps anyone, at work, I open sourced the UUID v7 postgresql function that I wrote: https://github.com/Betterment/postgresql-uuid-generate-v7
We've seen some amazing benefits, especially around improving the speed of batch inserts.
pg_idkit
-
Shrink UUIDs with PostgreSQL or Ruby
Unfortunately, as of PostgreSQL 16, UUIDv7 are not yet supported out of the box. For the time being, use an extension such as pg_uuidv7 or pg_idkit to generate UUIDv7 e.g. as default primary key when you CREATE new records.
-
UUIDv7 is coming in PostgreSQL 17
If you like this (I do very much), you might also like pg_idkit[0] which is a little extension with a bunch of other kinds of IDs that you can generate inside PG, thanks to the seriously awesome pgrx[1] and Rust.
[0]: https://github.com/VADOSWARE/pg_idkit
[1]: https://github.com/pgcentralfoundation/pgrx
- Pg_idkit: A Postgres extension for generating popular UUIDs
-
Bye Sequence, Hello UUIDv7
Yup this is one of the reasons I put together a light extension for this:
https://github.com/VADOSWARE/pg_idkit
There are a lot of options for UUID extensions (lots of great pure SQL ones!), but I wanted to get as many ID generation strategies in one place
Also note that native UUID v7 is slated to land in pg17:
https://commitfest.postgresql.org/44/4388/
- Pg_idkit: Postgres Extension for Generating UUIDs
-
ULIDs and Primary Keys
https://github.com/ulid/spec/issues
I went through this exploration a while back for a new project and decided on uuidv7s, which are binary compatible with ULIDs but will likely find more support as they get added to the original UUID RFC.
Either UUIDv7 or XIDs seem like better choices than ULIDs for new projects.
* Supabase on different primary key considerations: https://supabase.com/blog/choosing-a-postgres-primary-key
* Postgres extension for generating various kinds of IDs: https://github.com/VADOSWARE/pg_idkit
-
Introducing pg_idkit: A Postgres extension for generating UUIDs
I also made an issue in the repo so eventually I should get to expanding the benchmark set as well.
What are some alternatives?
cuid2 - Next generation guids. Secure, collision-resistant ids optimized for horizontal scaling and performance.
spec - The canonical spec for ulid
diesel - A safe, extensible ORM and Query Builder for Rust
cube.js - 📊 Cube — The Semantic Layer for Building Data Applications
ksuid - K-Sortable Globally Unique IDs
pgx - Build Postgres Extensions with Rust! [Moved to: https://github.com/tcdi/pgrx]
readyset - Readyset is a MySQL and Postgres wire-compatible caching layer that sits in front of existing databases to speed up queries and horizontally scale read throughput. Under the hood, ReadySet caches the results of cached select statements and incrementally updates these results over time as the underlying data changes.