uuidv7 Stops Random UUID Primary Keys From Killing InnoDB Write Performance
Switching from v4 to v7 can halve insertion latency in production, as Shopify reported, making it a low-cost win for systems that already use UUIDs. The catch is that v7 encodes creation time, so public-facing IDs need additional encoding to avoid leaking business volume.
Random UUID v4 primary keys cause InnoDB to scatter new rows across its clustered B+ tree, forcing page splits that drop fill rate to 50-60%, churn the buffer pool, and inflate WAL. The slowdowns only become visible after the table outgrows memory; before that, the buffer pool masks the cost. UUID v7 from RFC 9562 embeds a millisecond timestamp in the high bits, turning random placement into near-sequential appends, with write throughput reaching 85-89% of BIGINT auto-increment versus v4's 36% on MySQL.
PostgreSQL 18 ships native uuidv7() and a timestamp extraction function. MySQL 8.4 has no native v7, so you generate it in the application and store as BINARY(16) to avoid the char overhead. The trade-offs: v7 exposes the creation time, same-millisecond values aren't strictly ordered, and migrating a v4 table with foreign keys means rebuilding the clustered index and all FKs, a multi-hour lock operation. BIGINT auto-increment is still leaner and faster for single-database cases without external ID exposure.
The three-month quiet period before slowdowns appears is a memory threshold: once the hot portion of the B+ tree no longer fits in the buffer pool, page splits and cold-page evictions become visible. That makes the problem easy to miss until it's severe.
v7 is not a free upgrade; the timestamp prefix is a privacy leak. Systems that expose IDs in URLs or APIs must either stick with v4 or encode the ID before public release.
The migration cost described for existing tables is a strong argument for choosing the right key format at schema creation, because retrofitting a clustered index with foreign keys is a multi-hour lock operation.