我对这个问题也很疑问,在理论上,Hash index 在等值查询时,比BTree效率更加高,
但是在PostgreSQL中,无论是存储大小或等值查询,都不如BTree。
以下是PostgreSQL的官方文档。
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 may need to be rebuilt with REINDEX after a database crash. For these reasons, hash index use is presently discouraged.