UUIDs in Databases
Using UUIDs as primary keys sounds simple until you actually put one in production — then storage format, indexing, and engine-specific quirks start to matter. This section collects practical guides on storing, generating, and indexing UUIDs across PostgreSQL, MySQL, and MongoDB, plus the tradeoffs between UUIDs and traditional integer keys.
Choosing Between UUIDs and Other Key Strategies
- UUIDv4 vs UUIDv7 for Database Primary Keys: A Practical Comparison
- UUID as Primary Key: The Complete Storage & Indexing Tradeoffs Guide
- Composite Keys vs UUIDs: When Natural Keys Beat Surrogate UUIDs
- UUID Index Bloat Explained: B-Trees, Page Splits, and What to Do About It
- How Much Storage Do UUID Primary Keys Actually Cost at Scale? (Real Numbers)
PostgreSQL
- UUID vs BIGSERIAL as Primary Key in PostgreSQL: Which Should You Use?
- How to Store UUIDs Correctly in PostgreSQL (uuid type vs text vs varchar(36))
- Enabling gen_random_uuid() in Postgres: pgcrypto vs uuid-ossp vs Native (PG13+)
- UUID v7 in PostgreSQL: Native Support, Extensions, and Benchmarks
- Why Random UUIDs Fragment Your Postgres Index (and How to Fix It)
MySQL
- Storing UUIDs Efficiently in MySQL: BINARY(16) vs CHAR(36)
- UUID() vs AUTO_INCREMENT in MySQL: Performance Benchmarks
- MySQL UUID Functions Explained (UUID_TO_BIN, BIN_TO_UUID, is_swapped)
NoSQL
Tools and Versions
Need some UUIDs for testing? Try our tools for generating
UUIDv4
UUIDv7
ULID
NanoID
and
decoding
validating.
For a detailed comparison of UUID versions, visit our Complete Guide to UUID Versions.