Table of Contents
What Is a UUID?
A UUID (Universally Unique Identifier), standardized under RFC 4122 (and updated by RFC 9562), is a 128-bit identifier designed to guarantee uniqueness across distributed computing networks without requiring a central database coordination authority.
A standard UUID is represented as 32 hexadecimal digits separated by hyphens into five distinct groups: 8-4-4-4-12 (36 characters total including hyphens), for example:
550e8400-e29b-41d4-a716-446655440000
│ │ │ │ │
│ │ │ │ └── 48-bit Node identifier
│ │ │ └─────────── 2-bit Variant + 14-bit Clock Sequence
│ │ └────────────── 4-bit Version (e.g., 4 = v4)
│ └────────────────── 16-bit Timestamp (middle)
└────────────────────────── 32-bit Timestamp (low)
The Mathematics of UUID v4 Collisions
UUID version 4 utilizes 122 bits of pure pseudorandom entropy (6 bits are reserved for variant and version markers). The total number of possible UUID v4 combinations is 2^122 ≈ 5.3 × 10^36 (5.3 undecillion combinations).
To appreciate how astronomical this number is: if you generated one billion UUIDs every single second for 100 consecutive years, the probability of generating even a single duplicate ID is less than 0.00000000006%. You are thousands of times more likely to be struck by a meteorite while holding a winning lottery ticket.
The Evolution: UUID v1 vs v4 vs the New UUID v7
| Version | Generation Method | Key Advantage | Drawback |
|---|---|---|---|
| UUID v1 | 60-bit timestamp + MAC address | Chronologically sortable | Security leak: exposes device MAC hardware address and exact generation time. |
| UUID v4 | 122 bits of random data | Maximum privacy & simplicity | Database fragmentation: completely random keys shatter B-Tree index performance. |
| UUID v7 | 48-bit Unix millisecond timestamp + 74 bits random | Time-ordered & DB-optimized | Requires RFC 9562 library support. |
Why UUID v7 is the future: Modern high-performance relational databases (PostgreSQL, MySQL InnoDB) rely on B-Tree indexes for primary keys. Inserting random UUID v4 keys causes constant page splits and cache evictions. UUID v7 prefixes each identifier with a millisecond timestamp, ensuring new records append naturally to the end of index leaf pages like auto-incrementing integers while preserving global distributed uniqueness.
Generate RFC-compliant identifiers securely in your browser using FreeToolkit's UUID Generator.
Written by Dhaval Joshi. Have feedback or questions? Contact us at support@freetoolkit.online.