Which version should you pick?
- v4 (random) — the safe default for one-off random IDs. 122 bits of entropy means collisions are astronomically unlikely.
- v7 (RFC 9562) — best choice for database primary keys. The first 48 bits are a Unix millisecond timestamp, so rows insert in roughly time order and B-tree indexes stay tidy.
- v1 (time + node) — legacy timestamp-based UUID. Use only when interoperating with systems that already emit v1; v7 is strictly better for new code.
- v5 (SHA-1 namespace) — deterministic: the same (namespace, name) always produces the same UUID. Useful for turning URLs or DNS names into stable IDs.
- Nil / Max — special sentinel values, mostly used in tests and as "not set" markers.