Universally Unique Identifier
A 128-bit identifier that any machine can generate without coordination and still be practically certain no one else will produce the same one.
A universally unique identifier (UUID) is a 128-bit value, written as 32 hexadecimal digits in five groups, that can be generated independently by any machine with a negligible chance of colliding with any other. Microsoft calls them GUIDs. Their main use is identifying records, messages, files, and devices without a central authority handing out numbers.
The alternative is the auto-incrementing integer: the database assigns 1, 2, 3, and so on. It is compact, readable, and naturally ordered, but it has drawbacks:
- It needs coordination. Only the database knows the next number, so a client can't create an ID before saving, and sharded or offline systems can't generate IDs independently without collisions.
- It leaks information. Sequential IDs reveal how many orders or users exist and how fast they grow, and they invite users to guess other records' URLs, a risk if access checks are weak.
- It collides on merge. Two databases both have a record 42.
UUIDs remove the coordination. The common versions differ in how they get their uniqueness:
- Version 4 is 122 random bits. Collisions are so improbable that a billion IDs per second would take about 85 years to reach even odds of one, provided the random source is good.
- Version 7, standardized in 2024, puts a millisecond timestamp in front of random bits, so IDs sort roughly by creation time.
- Version 5 derives the ID from a hash of a name, so the same input always yields the same ID, a deterministic Hash Function use.
Sort order matters for databases. Random v4 IDs scatter inserts across a B-Tree index, splitting pages and wrecking cache locality, which slows writes on large tables. Time-ordered IDs, such as UUIDv7, ULID, and Twitter's Snowflake IDs (64 bits holding a timestamp, a machine number, and a sequence), append near the end of the index like an auto-increment does, while still being generated without coordination.
UUIDs let clients create records offline and sync later, as in Conflict-Free Replicated Data Type designs. They make operations safe to retry, since a request carrying its own ID can be deduplicated, which gives Idempotence. They also make Database Sharding and merging simple. The costs are size (16 bytes against 4 or 8), poor readability, and the false sense of security that unguessable IDs give. An unguessable ID is not access control.
See also3
Barcode
Patterns of bars or squares that machines read as numbers, which turned every product into a database key in the 1970s, and whose two-dimensional successors carry links, tickets, and payments.
Data & Content4 connections
Foreign Key
A column that points at a row in another table, with the database refusing any change that would leave the pointer dangling.
Data & Content11 connections
Idempotency Key
A unique token a client attaches to a request so the server can recognize a retry and return the original result instead of doing the work twice, the standard defense against double charges and duplicate orders.
Data & Content10 connections
Linked from7
- B-TreeComputation & Algorithms
A self-balancing tree with many children per node, designed to minimize the number of disk reads a lookup costs.
- BarcodeData & Content
Patterns of bars or squares that machines read as numbers, which turned every product into a database key in the 1970s, and whose two-dimensional successors carry links, tickets, and payments.
- Conflict-Free Replicated Data TypeNetworks & Distribution
A data structure whose replicas can be edited independently and always converge without coordination.
- Foreign KeyData & Content
A column that points at a row in another table, with the database refusing any change that would leave the pointer dangling.
- Idempotency KeyData & Content
A unique token a client attaches to a request so the server can recognize a retry and return the original result instead of doing the work twice, the standard defense against double charges and duplicate orders.
- Pseudorandom Number GeneratorComputation & Algorithms
An algorithm that produces a sequence of numbers that looks random but is fully determined by a starting seed, and the separate, stricter kind needed for security.
- SlugData & Content
The short, readable, hyphenated part of a URL that names a page, borrowed from newsroom jargon, simple to generate and surprisingly hard to keep stable once other people link to it.