diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-11 15:16:08 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-16 17:39:37 +0300 |
commit | a4a8cae7e1d4f5c72ddc0fce18d8530bf0e6c911 (patch) | |
tree | 2b0c30ed99c17577caad3b81b09c64da19ab4185 /doc/development/hash_indexes.md | |
parent | 6735e1dc9a3ae2e55c837f4ecea4bc3c6972a671 (diff) |
Document not using database hash indexes
Diffstat (limited to 'doc/development/hash_indexes.md')
-rw-r--r-- | doc/development/hash_indexes.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/development/hash_indexes.md b/doc/development/hash_indexes.md new file mode 100644 index 00000000000..e6c1b3590b1 --- /dev/null +++ b/doc/development/hash_indexes.md @@ -0,0 +1,20 @@ +# Hash Indexes + +Both PostgreSQL and MySQL support hash indexes besides the regular btree +indexes. Hash indexes however are to be avoided at all costs. While they may +_sometimes_ provide better performance the cost of rehashing can be very high. +More importantly: at least until PostgreSQL 10.0 hash indexes are not +WAL-logged, meaning they are not replicated to any replicas. From the PostgreSQL +documentation: + +> Hash index operations are not presently WAL-logged, so hash indexes might need +> to be rebuilt with REINDEX after a database crash if there were unwritten +> changes. Also, changes to hash indexes are not replicated over streaming or +> file-based replication after the initial base backup, so they give wrong +> answers to queries that subsequently use them. For these reasons, hash index +> use is presently discouraged. + +RuboCop is configured to register an offence when it detects the use of a hash +index. + +Instead of using hash indexes you should use regular btree indexes. |