Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

UUIDv4 vs. UUIDv7 vs. ULID in 2026: Index Performance and When to Migrate

UUIDv7 improves time-based index locality by design, but no identifier guarantees a universal performance gain. Compare its tradeoffs with UUIDv4 and ULID before adopting or migrating.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a new database key, UUIDv7 is usually the most direct choice when time ordering helps your index and exposing approximate creation time is acceptable. It is a standards-based 128-bit UUID designed to sort by generation time. UUIDv4 remains appropriate when random-looking identifiers matter more than insertion locality; ULID is a time-sortable alternative when its text representation and library support fit your stack. None guarantees a fixed performance gain: test against your database and workload before changing existing keys.

How UUIDv4, UUIDv7, and ULID differ

All three formats can identify records with 128-bit values, but they encode and order those values differently. That distinction affects insertion patterns and what an identifier reveals.

As an Amazon Associate I earn from qualifying purchases.

Comparison UUIDv4 UUIDv7 ULID
What it encodes Random or pseudorandom value; no generation-time order. RFC 9562 Unix-millisecond timestamp in the most significant 48 bits; the remaining 74 non-version/non-variant bits can use random data or optional precision and monotonicity mechanisms. RFC 9562 48-bit Unix-millisecond timestamp plus 80 bits of randomness. ULID specification
Ordering and index locality Generated values are scattered across keyspace, so inserts by key can land at distant index positions. RFC 9562 Designed to sort as opaque bytes by time, placing nearby generation times near each other in the ordered keyspace. RFC 9562 Canonical strings sort by time under the specified character ordering. Within one millisecond, order depends on the generator. ULID specification
Canonical text form 36-character UUID string; binary storage is also possible. RFC 9562 36-character UUID string; binary storage is also possible. RFC 9562 26 Crockford Base32 characters. The shorter text form alone does not prove smaller database storage. ULID specification
Timestamp visibility No embedded timestamp. Reveals approximate creation time and relative order. Reveals approximate creation time and relative order.
Standards and database support RFC UUID version; support depends on the database and generator. Standardized by RFC 9562; PostgreSQL 18 documents native UUIDv7 generation and UUID storage for any version. Separate specification and ecosystem convention; check the database representation, comparison rules, and library behavior.

For UUIDs, RFC 9562 recommends storing the underlying 128-bit binary value where feasible. It notes that text requires 288 bits to represent a UUID, while binary storage can take less space and may improve data access. This storage guidance is about UUIDs; do not infer that a 26-character ULID string will be smaller or faster in a particular database. The column type and index representation determine the actual footprint.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What index locality changes—and what it does not prove

A B-tree index organizes keys in sorted order. With UUIDv4, new random values can require inserts at unrelated positions. RFC 9562 describes this as poor database-index locality and says it can have a dramatic negative effect on B-trees and variants. UUIDv7 and time-ordered ULIDs instead put new values near the recent end of the ordered keyspace, which is a locality advantage by design. The RFC summarizes the principle: “Time-ordered monotonic UUIDs benefit from greater database-index locality because the new values are near each other in the index.”

Locality is not a guarantee that an index will never fragment or that a workload will become faster by a particular percentage. The available primary sources do not establish a controlled, generally applicable comparison of page splits, index size, write amplification, cache hit rate, latency, or read performance for these three identifiers. Engine behavior, schema, concurrency, generator implementation, and query patterns all affect the result.

Benchmark before treating a format change as an optimization

Compare formats using the same schema, row shape, indexes, database version, hardware, concurrency, transaction settings, and workload. Include realistic insert bursts, multiple generator instances, and clock behavior. Measure:

  • Insert throughput and latency.
  • Index size and engine-specific page-split or index-health indicators.
  • Index maintenance behavior and WAL or log volume, where relevant.
  • Representative read and query latency, not only inserts.

These are measurements to run on your target system, not published results for a universal workload.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generation order, monotonicity, and privacy

Same-millisecond and multi-generator behavior

UUIDv7 timestamps have millisecond resolution. RFC 9562 allows optional sub-millisecond precision and monotonicity mechanisms for generating multiple UUIDs during one timestamp tick, but the guarantee depends on the generator. PostgreSQL 18 documents its uuidv7() function as using Unix timestamp milliseconds plus sub-millisecond timestamp and random data.

The ULID specification describes a monotonic factory that increments the random component when it detects multiple calls in the same millisecond. Do not assume every ULID library uses that strategy. Verify the actual generator’s process or node scope, behavior when the clock moves backward, and handling of overflow. Without a monotonic strategy, same-millisecond ordering is not guaranteed by the ULID specification.

Time-bearing identifiers are not secrets

UUIDv7 and ULID reveal approximate creation time and ordering. RFC 9562 notes that UUID timestamps create a small attack surface and recommends UUIDv4 when UUIDs are required for a security operation in an application context. Regardless of version, an identifier should not serve as an authorization secret: enforce access control independently of whether a value is difficult to guess.

PostgreSQL 18: native UUIDv7 support

PostgreSQL 18 documents uuid as a 128-bit type that stores UUIDs conforming to RFC 9562 and accepts values from any UUID version, regardless of origin. It provides native UUIDv4 and UUIDv7 generation. That means a UUID-typed column can hold newly generated UUIDv7 values; it does not, by itself, convert existing keys or update foreign-key references.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PostgreSQL 18’s UUID functions documentation describes uuidv7() as time ordered and includes version and timestamp extraction functions. uuid_extract_timestamp works for versions 1 and 7, but PostgreSQL cautions that the extracted time is not necessarily the exact generation time because it depends on the generating implementation. Confirm the server version before relying on these functions. See the PostgreSQL UUID type documentation for storage and accepted values.

Which identifier should you choose?

Choose UUIDv7 for new records when locality matters

UUIDv7 is a practical default for a new system if your stack has a maintained, correct generator, time-based ordering is useful for the target workload, and approximate creation-time exposure is acceptable. It preserves the UUID format while providing ordered values, and PostgreSQL 18 can generate it natively.

Keep or choose UUIDv4 when randomness is valuable

UUIDv4 is still reasonable when random-looking identifiers suit your application or when the benefits of time ordering do not outweigh timestamp visibility and the other tradeoffs. Its index locality may be worse for insert-heavy B-tree workloads, so use measured index behavior—not the format alone—to decide whether that matters in your system.

Choose ULID when the representation and ecosystem fit

ULID can be a good fit when its 26-character Crockford Base32 form and available libraries are meaningful advantages. Check whether the database stores it as text or binary, how values are compared, and whether all generators provide the within-millisecond behavior your application expects. Its compact text form is a presentation characteristic, not evidence by itself of reduced database storage or improved index performance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When—and how—to migrate existing UUIDv4 keys

Changing identifiers is a measured optimization, not routine cleanup. First establish whether random-key insertion is a meaningful cost by profiling index size, insert behavior, write load, cache pressure, and query performance. If another bottleneck dominates, changing IDs may not address it.

If measurements support a migration, map every place the identifier is stored or relied upon before choosing a rollout. Primary keys often appear in foreign keys, external APIs, event payloads, caches, replicas, and application assumptions. A migration plan should address compatibility during rollout, uniqueness validation, backfill sequencing, rollback, and cutover. The RFC and PostgreSQL documentation do not prescribe a universal zero-downtime procedure or a threshold at which migration is worthwhile.

A lower-risk option: use UUIDv7 only for new rows

Keeping existing UUIDv4 values while generating UUIDv7 for new records can avoid rekeying legacy data. This works only if every consumer accepts mixed UUID versions and the application does not assume that every key is time ordered. Validate the mixed population against your workload and integrations; support for multiple UUID versions does not determine how an application handles them.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.