MySQL Adaptive Hash Index
The adaptive hash index is enabled by the innodb_adaptive_hash_index
variable, or turned off at server startup by --skip-innodb-adaptive-hash-index
.
Hash indexes are built on demand for the pages of the index that are accessed often.
Based on the observed pattern of searches, a hash index is built using a prefix of the index key. The prefix can be any length, and it may be that only some values in the B-tree appear in the hash index.
If a table fits almost entirely in main memory, a hash index speeds up queries by enabling direct lookup of any element, turning the index value into a sort of pointer. InnoDB
has a mechanism that monitors index searches. If InnoDB
notices that queries could benefit from building a hash index, it does so automatically.
Because it is difficult to predict in advance whether the adaptive hash index is appropriate for a particular system and workload, consider running benchmarks with it enabled and disabled.
The adaptive hash index feature is partitioned. Each index is bound to a specific partition, and each partition is protected by a separate latch. Partitioning is controlled by the innodb_adaptive_hash_index_parts
variable. The innodb_adaptive_hash_index_parts
variable is set to 8 by default. The maximum setting is 512.
#database