Why do random UUID keys make inserts slower?
An index is a tree of pages, kept in key order. Insert rows below and watch where each key lands, when a page fills up and splits, and how full the pages stay. Then switch from sequential ids to random UUIDs and do it again.
Random UUIDs need roughly a quarter to three-quarters more pages, depending on what you compare against. Notebook 10 measured 38.4 MB for a UUIDv4 index against 21.4 MB for bigint. They split far more often in the middle of the tree. Sequential ids only ever split the last page, so every page they leave behind is full. Random keys split pages in the middle, and both halves stay part-empty. Press "Compare all three key types" below to see it.
UUID_TO_BIN(uuid, 1) moves the time part of a version 1 UUID to the front. Keys arrive roughly in order, so you keep globally unique ids without the random inserts.Real pages are much bigger. Here a page holds 3 to 8 keys so you can see splits happen. A real 8 KB or 16 KB page holds hundreds of keys, so a table of millions of rows is only three or four levels deep. Real engines also leave a little room when they fill the last page: PostgreSQL B-tree indexes leave 10% free by default (fillfactor 90), and InnoDB tries to leave 1/16 of the page free. Tables default to fillfactor 100, so a table page is packed full.
Where this matters next: MySQL · InnoDB for the clustered index, why column order matters in an index, and the Query coach, which flags a UUID string primary key in InnoDB.
The same mechanism, keys and ids, indexes and plans, elsewhere on the site: in real incidents, in measurements, and in designs.
Can I see it happen? Simulations, an index you build yourself, a real PostgreSQL in your browser, experiments run on real servers, and tools for your own database: a query coach, an EXPLAIN reader, a config checker and a health check.