When UUIDs beat sequential IDs
UUIDs let you assign an ID before insert, merge data from multiple sources without renumbering, and expose opaque keys in URLs. For local prototypes and QA datasets, generating a batch here is faster than importing a library.
Format and standards
RFC 4122 defines versions and variant bits. Version 4 fills most bits randomly; versions 1 and 7 embed time or sortable structure. Match the version your ORM or API contract expects.
Storage and indexing
Random UUIDs fragment B-tree indexes more than sequential integers. Some teams store UUIDs as binary(16) or adopt UUIDv7 for time-ordered clustering. Measure index size if you expect billions of rows.
Security note
UUIDs are identifiers, not secrets. Do not use them alone for session tokens or password-reset links—pair with signed, expiring tokens instead.