UUIDs (Universally Unique Identifiers) are 128-bit identifiers used across databases, APIs, distributed systems, and virtually every modern application. With the new UUID v7 specification gaining adoption, it's worth understanding which version to use and why.
UUID Versions Explained
UUID v1: Based on timestamp + MAC address. Provides uniqueness but leaks the generating machine's MAC address — a privacy concern. Rarely used in new applications.
UUID v4: Completely random (122 bits of randomness). The most widely used version due to simplicity. No information leakage, but random distribution causes B-tree index fragmentation in databases.
UUID v7 (new): Timestamp-prefixed + random. Defined in RFC 9562 (2024). Combines the privacy of v4 with the sortability of v1. The 48-bit Unix timestamp prefix means UUIDs sort chronologically, dramatically improving database index performance.
UUID v4 vs v7: When to Use Each
Use v4 when: You need simple randomness, don't care about sort order, or need maximum privacy (no temporal information in the ID).
Use v7 when: IDs are used as database primary keys (better B-tree performance), you need approximate creation timestamps embedded in IDs, or you want IDs that sort chronologically.
Database Performance
Random UUID v4 primary keys cause significant B-tree fragmentation because new inserts scatter across the entire index. This leads to more page splits, higher write amplification, and larger index sizes. UUID v7 solves this by ensuring new IDs always sort after existing ones, providing insert performance similar to auto-increment while retaining UUID benefits.
UUID vs Auto-Increment
Auto-increment IDs are simpler and more compact (8 bytes vs 16) but require a centralized authority. UUIDs can be generated independently on any machine without coordination — essential for distributed systems, offline-capable apps, and microservice architectures.
Generate UUIDs instantly with our UUID Generator — supports v4, v7, and bulk generation.