我猜创建哈希索引是 O(n),而用它来访问数据也得到 O(n),所以,它比 b-tree 索引更好?
最佳答案
来自manual :
Note: Testing has shown PostgreSQL's hash indexes to perform no better than B-tree indexes, and the index size and build time for hash indexes is much worse. Furthermore, hash index operations are not presently WAL-logged, so hash indexes might need to be rebuilt with REINDEX after a database crash. For these reasons, hash index use is presently discouraged.
手册的后续版本不再提及性能问题,只关注复制问题。
看起来使用哈希索引没有意义。
关于postgresql - PostgreSQL 哈希索引的时间复杂度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28808753/