Database · Medium
B-tree vs hash index — how do they work and when do you use each?
DatabaseIndexingSenior
Answer preview
A B-tree stores keys in sorted order, so it serves equality, ranges, sorting, and prefix matches. A hash index stores only a hash of the key in buckets, so it serves = alone — but in O(1) with a smaller footprint on long keys.…