pg_tuid
sequential-uuids
pg_tuid | sequential-uuids | |
---|---|---|
4 | 7 | |
115 | 294 | |
- | - | |
0.0 | 3.6 | |
over 1 year ago | 7 months ago | |
PLpgSQL | C | |
MIT License | MIT License |
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.
pg_tuid
-
PostgreSQL reached maximum value of sequence (2147483627)
If you don't want to wait on official UUID6/7/8 support you can roll your own. I've got a version here.
- Custom unique PK against generated UUIDV4 performance.
-
Understanding UUIDs, ULIDs and String Representations
You can also time prefix uuids via something like https://github.com/tanglebones/pg_tuid.
-
UUID vs int for primary key - Which is better (with auto increment), especially if you are scared you'll run out of ids?
Use some kind of time-prefix system (e.g. https://github.com/tanglebones/pg_tuid) over uuid.
sequential-uuids
-
Choosing a Postgres Primary Key
Disclaimer: not a dba so my terms might not be appropriate
I’ve seen uuid4 which replaces the first 4 bytes with a timestamp. It was mentioned to me that this strategy allows postgres to write at the end of the index instead of arbitrarily on disk. I also presume it means it has some decent sorting.
[inspiration](https://github.com/tvondra/sequential-uuids/blob/master/sequ...)
-
Install extensions from PGDG repo to YugabyteDB - example with sequential_uuids
yum install -y git git clone https://github.com/tvondra/sequential-uuids.git ysqlsh -h $(hostname) --echo-all --quiet \ --file sequential-uuids/test/sql/uuids.sql | sdiff sequential-uuids/test/expected/uuids.out -
-
Using a custom GUID (not provided by Postgres). What to keep in mind for performance gains
If you want to keep locality when using uuids, use a different generation function such as: https://github.com/tvondra/sequential-uuids
-
Any significant performance disadvantage to using uuid as primary key?
OP, have a pretty large B2B SAAS app with all UUID pkeys, and the largest issues i'd say with UUID compared to bigint are: size, index bloat, WAL bloat, much slower GIST indexes (for exclusion constraints). You can work around some of the issues (WAL bloat, index bloat) by using a better behaved UUID generation function: https://github.com/tvondra/sequential-uuids You can get something similar for your app side of things if you need to generate UUIDs there.
-
Timeflake: 128-bit, roughly-ordered, URL-safe UUIDs
Use this: https://github.com/tvondra/sequential-uuids
If you cannot install extensions, I just wrote a PL/PGSQL implementation for the time-based generator I could share.
-
UUID vs int for primary key - Which is better (with auto increment), especially if you are scared you'll run out of ids?
Just fyi, UUID in Postgres is not 40 text chars, it's 16 bytes binary and has a canonical text representation. Also, you don't need to use UUIDv4, I am quite partial to: https://github.com/tvondra/sequential-uuids
What are some alternatives?
Pomelo.EntityFrameworkCore.MySql - Entity Framework Core provider for MySQL and MariaDB built on top of MySqlConnector
timeflake - Timeflake is a 128-bit, roughly-ordered, URL-safe UUID.
id128 - 128-bit id generation in multiple formats
uulid.go - ULID-UUID compatibility library for generating and parsing ULIDs.
umbrella - ⛱ Broadly scoped ecosystem & mono-repository of 192 TypeScript projects (and 157 examples) for general purpose, functional, data driven development
pg_tle - Framework for building trusted language extensions for PostgreSQL