Инструменты Intosoft
🆔

UUID Versions Explained

A complete guide to UUID versions 1 through 7. Understand the trade-offs and choose the right version for your application.

✅ Quick Recommendation

General use: Use UUID v4 (random). Simple, widely supported, good for most APIs.

Database primary keys: Use UUID v7 (time-sorted). Much better index performance.

Deterministic IDs: Use UUID v5 (namespace). Same input always produces same UUID.

UUID Format (128 bits)

550e8400-e29b-41d4-a716-446655440000
time_low
32 bits
time_mid
16 bits
version + time_hi
16 bits
variant + clock_seq
16 bits
node
48 bits

The "4" in position 13 indicates version (v4). The "a" in position 17 indicates variant (RFC 4122).

All UUID Versions

UUID v1: Time-based

Timestamp + MAC address

f47ac10b-58cc-11e1-a4f1-0026b9c4f1f1
✅ Pros
  • • Sortable by time (roughly)
  • • No collision risk
  • • Can extract timestamp
❌ Cons
  • • Exposes MAC address (privacy)
  • • Sequential = guessable
  • • Clock sync issues

Best for: Legacy systems, audit logs

UUID v2: DCE Security

Timestamp + local domain ID

000003e8-0c1a-21e7-8800-84cda8a2b101
✅ Pros
  • • POSIX-compliant
  • • Domain-scoped
❌ Cons
  • • Rarely used
  • • Complex implementation
  • • Poor documentation

Best for: DCE/POSIX environments only

UUID v3: Namespace (MD5)

MD5 hash of namespace + name

5df41881-3aed-3515-88a7-2f4a814cf09e
✅ Pros
  • • Deterministic (same input = same UUID)
  • • No external dependencies
❌ Cons
  • • MD5 is cryptographically weak
  • • Prefer v5 for new projects

Best for: Deterministic IDs from names

UUID v4: Random

122 random bits

✓ Recommended
550e8400-e29b-41d4-a716-446655440000
✅ Pros
  • • Simple
  • • No privacy concerns
  • • Unpredictable
  • • Most libraries support
❌ Cons
  • • Not sortable
  • • Poor database index performance
  • • Theoretical collision risk

Best for: General purpose, APIs, tokens

UUID v5: Namespace (SHA-1)

SHA-1 hash of namespace + name

✓ Recommended
2ed6657d-e927-568b-95e1-2665a8aea6a2
✅ Pros
  • • Deterministic
  • • Stronger than v3
  • • Same input = same UUID
❌ Cons
  • • SHA-1 deprecated for security
  • • Still fine for UUID generation

Best for: Deterministic IDs, URL-to-UUID

UUID v6: Reordered Time

v1 bits reordered for sorting

1e11158c-caf4-6680-a4f1-0026b9c4f1f1
✅ Pros
  • • Time-sortable (lexicographically)
  • • Compatible with v1 systems
❌ Cons
  • • Still exposes MAC
  • • Less adopted than v7

Best for: Drop-in v1 replacement needing sort

UUID v7: Unix Time + Random

48-bit Unix timestamp ms + 74 random bits

✓ Recommended
018e9c74-b5d0-7123-8d9a-7c9a8d9e0f1a
✅ Pros
  • • Time-sortable
  • • No MAC exposure
  • • DB index friendly
  • • Future standard
❌ Cons
  • • Newer, less library support
  • • Draft RFC (as of 2024)

Best for: New projects, databases, distributed systems

Quick Comparison

VersionSortable?Deterministic?Privacy Safe?DB Perf?
v1~TimeNo❌ MAC exposedMedium
v4RandomNo✅ RandomPoor
v5Hash-based✅ Yes✅ SafeMedium
v7✅ TimeNo✅ Safe✅ Excellent

Database Performance

Index Performance

v4 UUIDs cause random inserts, fragmenting B-tree indexes. v7 UUIDs insert sequentially, improving performance 10-100x.

💡 Use v7 for primary keys in high-write databases

Storage Size

All UUIDs are 128 bits (16 bytes). Store as BINARY(16) or native UUID type, not VARCHAR(36).

💡 Save 56% space using binary storage

Collision Risk

With 122 random bits (v4), 2.71×10^18 UUIDs needed for 50% collision probability. In practice: virtually impossible.

💡 Don't worry about collisions in v4/v7

Generate UUIDs Instantly!

Create v4 and v7 UUIDs with our free generator tool.

🆔Open UUID Generator