logoalt Hacker News

saagarjha • yesterday at 6:52 PM • 2 replies • view on HN

Sounds like the problem here is that databases need to index on more than one thing at once


Replies

cpburns2009 • yesterday at 7:23 PM

They already do. UUIDv7 neatly solves a common problem: a random, unguessable, public id that works well with databaes. UUIDv4 is infamous for this.

➕ show 1 reply
debazel • yesterday at 7:50 PM

It doesn’t have anything to do with indexing more than one thing.

The issue with truly random IDs is that inserts are scattered throughout the B-tree index, which cause page splits, fragmentation, and poor cache locality. Using a timestamp prefix makes new IDs sequential, so inserts tend to land near the end of the index, which avoid all the B-tree trashing and improve write performance.

➕ show 1 reply