1--- 2stage: Enablement 3group: Database 4info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments 5--- 6 7# Hash Indexes 8 9PostgreSQL supports hash indexes besides the regular B-tree 10indexes. Hash indexes however are to be avoided at all costs. While they may 11_sometimes_ provide better performance the cost of rehashing can be very high. 12More importantly: at least until PostgreSQL 10.0 hash indexes are not 13WAL-logged, meaning they are not replicated to any replicas. From the PostgreSQL 14documentation: 15 16> Hash index operations are not presently WAL-logged, so hash indexes might need 17> to be rebuilt with REINDEX after a database crash if there were unwritten 18> changes. Also, changes to hash indexes are not replicated over streaming or 19> file-based replication after the initial base backup, so they give wrong 20> answers to queries that subsequently use them. For these reasons, hash index 21> use is presently discouraged. 22 23RuboCop is configured to register an offense when it detects the use of a hash 24index. 25 26Instead of using hash indexes you should use regular B-tree indexes. 27