3 ms·
Does random UUID work as well as lets say an ordered integer id or ordered uuid? I thought the ids should have a definite order(not necessarily sequential) so t
by abhishekjha 6y ago
Does random UUID work as well as lets say an ordered integer id or ordered uuid? I thought the ids should have a definite order(not necessarily sequential) so that a binary search can be performed on the primary index. Similar for b-trees.
- masklinn 6y agoRandom uuids are perfectly ordered, there’s no issue looking up a single record by uuid. The problems are that they’re scattered during reads and writes, and will require updating old pages.
- kevincox 6y agoNote that scattering can actually be beneficial if you have too much load for a single node when the data is hot. Of course you can solve this with weird sharding such as sharding on the least significant byte.
- SigmundA 6y agoSeems like this point is not understood very well by many. Ordered keys can create hot spots on insert and read, this can be good or bad depending on backend.
- kevincox 6y agoThe classic goldilocks problem. You want your pages to be hot, but not too hot.
- mywittyname 6y agoA hot-spot in one database index is collocated data in another. Sometimes you want uniform distribution of keys, sometimes you want clusters of keys because different databases are optimized based on assumptions about the underlying distribution of keys.