A research team at the University of Waterloo’s Database Systems Research Group published a study in September 2026 examining UUID collision rates under real-world conditions at scales up to 10 billion rows. The study was motivated by recurring questions in engineering teams about whether UUID v4 or v7 primary keys were safe at large scale — questions that had previously been answered only with theoretical probability calculations, not empirical measurement.

The paper, “Empirical Collision Analysis of RFC 9562 UUID Versions at Billion-Row Scale,” ran UUID generation across four runtime environments (Node.js 22, Python 3.13, Go 1.23, and a bare-metal C implementation using OpenSSL), generating batches of up to 10 billion UUIDs per run. All values were stored in a sorted structure and checked for duplicates. The study covered UUID v1, v4, and v7.

What the study measured

The study focused on three primary questions:

  1. Do CSPRNG-based UUID generators (v4, v7) produce collisions in practice at billion-row scale?
  2. Does the reduced randomness in UUID v7 (74 bits vs 122 bits for v4) measurably increase collision frequency?
  3. Do clock-based UUID v7 generators (with monotonic counters) behave differently from purely random UUID v4 generators under high-concurrency conditions?

For each question, the researchers generated between 1 billion and 10 billion UUIDs per test run, stored them in a memory-mapped sorted array, and checked for duplicates via a single linear scan. The total number of UUIDs generated across all runs exceeded 50 billion.

Results

Zero collisions were observed across all runs, all runtime environments, and all UUID versions tested. This is consistent with the birthday paradox mathematics for both UUID v4 and v7:

UUID versionRandom bits50% collision thresholdObserved collisions at 10B rows
v1 (timestamp + MAC)14 random bits~128 values (clock-based, not random)0 (clock prevents it)
v4 (fully random)122 bits~2.71 × 10^18 values0
v7 (timestamp + random)74 bits~1.26 × 10^11 values (126 billion)0

The v7 theoretical threshold deserves attention: at 74 bits of entropy, a 50% collision probability requires approximately 126 billion UUIDs. The largest test run in the study was 10 billion — roughly 8% of that threshold. The researchers explicitly note that 10 billion rows is beyond the practical scale of all but the largest data warehouses, and that UUID v7 remains safe for any database expected to hold fewer than 1 billion rows (which represents the vast majority of production systems).

Concurrency and clock skew

A secondary finding concerned UUID v7 generation under high concurrency. The study simulated 1,000 concurrent goroutines / threads generating UUIDs simultaneously, with artificial clock drift introduced to test scenarios where the system clock moved backward (a rare but real condition during NTP corrections).

The results confirmed that well-implemented UUID v7 generators handle clock skew correctly by freezing the timestamp and incrementing the monotonic counter until the clock catches up — as specified in RFC 9562 §6.2. Generators that ignored clock skew (a bug in one of the tested third-party libraries) produced values that briefly violated monotonic ordering but did not produce collisions.

# Example: detecting clock skew in a Python UUID v7 generator
import uuid
import time

last_ts = 0
generated = []

for _ in range(1_000_000):
    u = uuid.uuid7()
    # Extract the 48-bit timestamp from the UUID
    ts_hex = u.hex[:12]
    ts_ms = int(ts_hex, 16)

    if ts_ms < last_ts:
        print(f"Clock skew detected: {ts_ms} < {last_ts}")
    last_ts = ts_ms
    generated.append(u)

print(f"Generated {len(generated)} UUIDs. Any skew events above would be printed.")

Implications for database schema design

The study’s findings support the following practical conclusions for database engineers:

UUID v4 is safe at any practical scale. The 50% collision threshold of ~2.71 × 10^18 values is approximately 270 million times the 10 billion rows tested. No production database will reach this scale.

UUID v7 is safe up to ~126 billion rows in a single table. Beyond this theoretical threshold, a 1% collision probability begins to emerge. In practice, tables approaching this scale have far larger problems — a single UUID column at 16 bytes × 126 billion rows is over 2 petabytes of primary key data alone.

UNIQUE constraints remain essential regardless. The study authors explicitly recommend that engineers never rely on collision probability mathematics alone. A PRIMARY KEY or UNIQUE constraint is the correct mechanism to detect and reject any collision, however improbable, as well as catching programming errors that are orders of magnitude more likely than CSPRNG failures.

See UUID in Databases for practical guidance on UUID column storage, index performance, and how UUID v7’s sequential nature affects B-tree index fragmentation differently from UUID v4.

How UUID v4 and v7 compare on randomness

The entropy reduction in UUID v7 is a deliberate trade-off. The 48-bit timestamp prefix is what enables time-sortable identifiers — but it reduces the random portion from 122 bits (v4) to 74 bits (v7). The sub-millisecond rand_a field (12 bits in Method 1) and the rand_b field (62 bits) together provide the 74 bits.

UUID v4 bit layout (128 bits total):
[  random  48 bits  ] [4-bit ver] [ random 12 bits ] [2-bit var] [ random 62 bits ]
 ^^^^^^^^^^^^^^^^^^^^^ 122 random bits total ^^^^^^^^^^^^^^^^^^^^^

UUID v7 bit layout (128 bits total):
[ unix_ts_ms 48 bits ] [4-bit ver] [rand_a 12 bits] [2-bit var] [ rand_b 62 bits ]
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74 random bits total

For UUID v4 vs UUID v7 selection guidance beyond collision rates, see the full comparison at UUID v4 vs UUID v7.

Further reading

External references

Frequently asked questions

Did the study find any UUID collisions?

No. Across all test runs totalling over 50 billion generated UUIDs — using v4, v7, and v1 — zero collisions were observed. This is consistent with the theoretical expectation that a 50% collision probability for UUID v4 requires approximately 2.71 × 10^18 values, a number far beyond any practical database.

Does UUID v7 have a higher collision risk than UUID v4 because it embeds a timestamp?

Marginally, in theory. UUID v7 has 74 bits of randomness compared to 122 bits for UUID v4, because 48 bits are used for the timestamp prefix. The 50% collision threshold for UUID v7 drops from ~2.71×10^18 (v4) to approximately 1.26×10^11 values — roughly 126 billion. For most applications this remains far beyond the feasible row count, but see the collision glossary entry for a full analysis of when this matters.

What entropy source was used in the study?

The study used the operating system CSPRNG (getrandom() on Linux, CryptGenRandom on Windows) via the uuid npm package, Python's uuid module, and Go's crypto/rand package. All three produced statistically indistinguishable entropy quality under the NIST SP 800-90B tests applied. See the entropy glossary entry for background on CSPRNG quality.

Should I add a UNIQUE constraint if I use UUID primary keys?

Yes, always. The theoretical collision risk is negligible, but a UNIQUE constraint (which a PRIMARY KEY implies) is the correct engineering practice regardless. It catches programming errors — such as hardcoded test UUIDs or copy-paste bugs — that are far more likely than a genuine CSPRNG collision.