UUIDs Are Everywhere
Universally Unique Identifiers (UUIDs) are 128-bit values used to identify resources without a central authority. They look like this:
550e8400-e29b-41d4-a716-446655440000If you've built a web app, you've used UUIDs — for user IDs, session tokens, API keys, database primary keys, or trace IDs.
UUID v4: The Random Standard
UUID v4 is the most widely used version. It's 122 bits of random data plus 6 bits of version/variant info.
Pros:
- Truly random — no information leakage
- Supported everywhere
- Simple to generate
Cons:
- Not sortable by time
- Poor database index performance (random insertion)
- No embedded timestamp
UUID v7: The New Default
UUID v7 (RFC 9562, finalized 2024) embeds a Unix timestamp in the first 48 bits, followed by random data.
Pros:
- Time-sortable — newer IDs sort after older ones
- Excellent database index performance (sequential insertion)
- Embedded timestamp for debugging
- Still unique enough for distributed systems
Cons:
- Leaks creation time (privacy consideration)
- Newer — not all libraries support it yet
When to Use Each
| Use Case | Recommendation |
|---|---|
| Database primary keys | UUID v7 (better index performance) |
| Session tokens | UUID v4 (no timestamp leakage) |
| API keys | UUID v4 (no information leakage) |
| Distributed trace IDs | UUID v7 (time-sortable for debugging) |
| File names | UUID v4 (unpredictable) |
| Event/log IDs | UUID v7 (time-ordered) |
The Database Performance Difference
With UUID v4, new records insert at random positions in the B-tree index. This causes page splits and fragmentation — especially painful at scale.
With UUID v7, new records always insert at the end of the index (like auto-increment). This means sequential writes, no page splits, and much better write performance.
Benchmarks show UUID v7 primary keys can be 2-3x faster for write-heavy workloads compared to UUID v4.
Generate UUIDs Now
Need UUIDs quickly? Use our [free UUID generator](/tools/uuid-generator). Generate up to 100 at a time in standard, uppercase, or no-dash format.
UUIDs in Error Tracking
Every error event in Bugsly gets a UUID v7 event ID — time-sortable so you can correlate events chronologically across services. When you're debugging a distributed system and need to trace an error across microservices, time-ordered IDs make the timeline obvious. [Start tracking](/signup).
Try Bugsly Free
AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.
Get Started FreeRelated Articles
How to Fix Rangeerror in Node.js
Learn how to diagnose and fix the rangeerror in Node.js. Includes code examples and prevention tips.
Read moreHow to Fix Version Mismatch in Kotlin
Learn how to diagnose and fix Version Mismatch errors in Kotlin. Step-by-step guide with code examples.
Read moreFix TimeoutError in Go
Step-by-step guide to fix TimeoutError in Go. Includes root cause analysis, code examples, debugging tips, and prevention strategies.
Read moreHow to Fix Web Worker Error in Svelte
Struggling with Web Worker Error in Svelte? This guide explains why it happens and how to resolve it quickly.
Read more