UUID v4 vs v7 — Sortable IDs in New Projects
UUID v4 is random; UUID v7 is time-ordered for better database index locality. When to pick v7 for new APIs, and when v4 still makes sense.
By Vertex Solutions Editorial
Primary key inserts on UUID v4 looked random — because they were. Postgres index pages split constantly at 50M rows. Query plans scanning WHERE created_at > yesterday still hit random leaf pages because PK order ≠ time order.
UUID v7 doesn't replace v4 everywhere. It fixes a specific pain: time-correlated inserts with random UUID primary keys.
Quick answer
Primary key inserts on UUID v4 looked random — because they were. Postgres index pages split constantly at 50M rows. Query plans scanning WHERE created_at > yesterday still hit random leaf pages because PK order ≠ time order.
UUID v4 recap
- 122 random bits + version/variant bits
- No semantic meaning
- Excellent unpredictability for public tokens
- Poor insertion locality in B-trees
How UUIDs Work, UUID in API Development.
UUID v7 recap
- 48-bit Unix ms timestamp (top)
- Random bits fill remainder
- Roughly sortable by creation time
- Better index append patterns
- Leaks timing — trade privacy for performance
Standardized in RFC 9562 (2024).
Comparison table
| Aspect | v4 | v7 | | --- | --- | --- | | Sortable by time | No | Approximate yes | | Index locality | Poor | Better | | Guessability | Very low | Timestamp visible | | Library support | Universal | Growing | | Public exposure | Safer opaque | Consider exposure |
When to choose v7
- High-volume OLTP with UUID PK
- Range queries on ID as proxy for time
- Distributed generators without central sequence
- New greenfield Postgres/MySQL designs
When to stay v4
- Public session tokens in URLs
- Low volume apps — premature optimization
- Runtimes without v7 yet in prod
- Security requirement for non-guessable opaque IDs
Hybrid pattern: internal v7 PK, external opaque public_id v4 column.
Database notes
Postgres — uuid type; v7 benefits B-tree on id. Still use created_at for precise time — don't rely on v7 ms alone in distributed clocks.
MySQL — UUID as BINARY(16) stores efficiently; v7 hex sort ≈ time sort.
SQLite — less critical at small scale.
Collision and clock skew
v7 assumes reasonable clock sync. NTP skew across generators can produce out-of-order IDs rarely — acceptable for most apps; not for strict monotonic global ordering (use Snowflake IDs instead).
Generate test IDs in UUID Generator.
Migration from v4
Don't rewrite existing PKs. New tables v7; old tables v4. Mixed DB fine.
JSON APIs
IDs as strings "018f3e2a-..." — validate format — JSON Schema Validation.
Troubleshooting
What is the difference between UUID v4 and v7? UUID v4 is mostly random with 122 bits of randomness. UUID v7 encodes a Unix timestamp in the most significant bits with random bits below — making IDs roughly time-sortable while remaining globally unique without coordination.
Why use UUID v7 instead of v4? v7 improves B-tree index locality in databases — newer rows cluster near each other reducing page splits and improving range query performance on primary keys ordered by insertion time.
Is UUID v4 still fine for new projects? Yes for many apps where insert order indexing doesn't matter or volumes are moderate. v4 is universally supported everywhere v7 isn't yet. v7 is increasingly supported in Postgres 18+, libraries, and language runtimes.
Limitations
Browser-based workflows for uuid v4 vs v7 depend on file size, browser memory, and how the source file was created. Very large files, password-protected inputs, or unusual encodings may fail without a desktop alternative. Always keep an original copy before batch processing.
When not to use this approach
Skip browser-only processing when compliance requires audit logs, when files exceed practical browser limits, or when you need features your browser tool does not expose (bookmarks, form fields, digital signatures). In those cases, use dedicated desktop software or an approved enterprise pipeline.
Related tools
Conclusion
v7 for new high-volume time-ordered PKs; v4 for opaque public tokens and universal compatibility.
Timestamp leak is real — don't put v7 in customer-visible URLs if timing is sensitive. Index locality is real too — at 50M rows you'll notice.
ULID and Snowflake alternatives
UUID v7 not only sortable ID — ULID (Crockford base32) human-transcribable; Snowflake IDs need central worker ID allocation. Compare when v7 timestamp leak unacceptable but sortability needed.
Database index type
Postgres B-tree default; UUID PK works. Consider BRIN on created_at column separately if queries time-range heavy — v7 helps but dedicated timestamp column clearer for analytics.
Logging correlation
v7 IDs sortable in log grep approximate time window — useful debugging production without separate timestamp column in log line if ID logged.
Putting this into practice this week
Pick one workflow from this article and run it on a real task today — not a hypothetical. If the guide covers PDF export, export one document you already need for work. If it covers image naming, rename one messy folder. Knowledge retained from doing beats knowledge retained from reading.
Questions to ask before you delegate
When handing a process to a teammate or virtual assistant, ask: "What would break if you skipped step three?" If they can't answer, the process isn't documented enough. Add the missing step to your internal wiki with a link to this guide and the relevant tool page.
How this connects to the broader site
Utility-first sites win when guides and tools reinforce each other. Bookmark the tool URL alongside this article. Share the article link when onboarding someone who'll use the tool weekly — context reduces support messages asking the same formatting question twice.
Common "it worked yesterday" causes
Software updates change export defaults. Browser updates change PDF print behavior. CDN cache serves old image after you uploaded new asset. When workflows break without code changes, check version changelogs before blaming user error. First troubleshooting step: reproduce in clean browser profile with extensions disabled.
When to escalate to a specialist
Tax, legal, medical, and enterprise security topics in adjacent guides sometimes require professional advice. Articles like this explain operational literacy — not professional services. Escalate when stakes exceed convenience (court filing, audit response, M&A data room, HIPAA-covered PHI).
Quick reference checklist
Before you close the tab, confirm the basics from this guide:
- You know which tool or export path applies to your exact file type
- You've tested output on the device or platform your audience uses
- Filename, margins, or metadata won't embarrass you in a professional context
- You've linked related guides for the next step in the workflow
- Sensitive data stayed in the processing tier your policy allows (browser vs cloud)
Print or save this checklist for onboarding teammates — utility workflows fail from skipped verification, not missing features.
Related reading on this site
Browse the blog category cluster this article belongs to for deeper dives. Tool pages linked in-body are the fastest path from reading to doing. If something in the workflow still feels fuzzy, that's a signal to run one real file through the pipeline and note where friction appeared — then re-read the section that matches that step.
Final reminder
Good document and media hygiene compounds. An extra ninety seconds at export time prevents ninety minutes of rework when a client, professor, printer, or auditor sends the file back. The tools exist to make that ninety seconds painless — use them deliberately rather than hoping defaults match your stakes.
Frequently Asked Questions
Common questions answered to help you get the most from this tool.