UUID v4 vs UUID v7: Full Comparison
UUID v4 generates purely random identifiers, while UUID v7 (proposed in RFC 9562) embeds a Unix timestamp for time-ordered sorting. Both are 128-bit identifiers, but v7's time-ordering gives it significant database performance advantages.
| Feature | UUID v4 | UUID v7 |
|---|---|---|
| Generation | 122 random bits | 48-bit timestamp + 74 random bits |
| Sortable | No — completely random | Yes — time-ordered |
| Database Index Performance | Poor — random write patterns | Excellent — sequential writes |
| Collision Probability | 2^-61 (extremely low) | 2^-74 per millisecond (lower) |
| Time Extractable | No | Yes — timestamp embedded |
| Standard | RFC 4122 (established) | RFC 9562 (2024, new) |
| Privacy | No info leakage | Creation time is visible |
| Best For | General purpose, privacy-sensitive | Databases, event logs, time-series |
Verdict: Which Should You Use?
Use UUID v7 for database primary keys and anything that benefits from time-ordering. Use UUID v4 when you need privacy (no timestamp leakage) or maximum compatibility. Generate both with Quill Tools' free UUID Generator.