All Questions
Scaling Reads hard

Why does using random UUID v4 as a Primary Key hurt Read performance in a large B-Tree database compared to sequential Integers or ULIDs?

  1. A UUIDs take up more space (128-bit vs 64-bit).
  2. B UUIDs cannot be indexed.
  3. C Random UUIDs cause 'Page Fragmentation' (Random Writes) in the B-Tree, spreading related data across random disk pages. This forces the DB to load more pages into RAM to satisfy queries, lowering the cache hit ratio.
  4. D UUIDs require encryption.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions