3 ms·
Isn’t there also hash based index for random keys?
by wbsun 2y ago
Isn’t there also hash based index for random keys?
- benwilber0 2y agoMaybe? idk. Not in Postgres. The default index is a B-Tree. A hash-based index would be terrible for disk-seeking, in any case.
- eurleif 2y agohttps://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-HASH https://www.postgresql.org/docs/current/indexes-types.html#I...
- benwilber0 2y agoProbably the worst PK index of all time. There's a reason why it's barely ever used.
- paperplatter 2y agoPostgres has it, but it didn't used to, and it's still got caveats. Beyond Postgres, indexing random values is fundamentally harder than indexing sorted ones, whether you've got a hashmap or btree or something else. The often-cited O(1) lookup complexity of a hashmap assumes everything easily fits in uniform-access memory.