📜  innodb_adaptive_hash_index (1)

📅  最后修改于: 2023-12-03 15:01:24.641000             🧑  作者: Mango

InnoDB Adaptive Hash Index

Introduction

InnoDB is a storage engine used by MySQL and MariaDB. InnoDB Adaptive Hash Index is a feature that intelligently manages the InnoDB buffer pool and speeds up lookups.

How it Works

InnoDB Adaptive Hash Index is a data structure that enables rapid lookups in large datasets. It uses an in-memory hash table to cache frequently accessed index pages. When a page is accessed frequently, it is added to the hash table. This allows future lookups to be performed quickly without the need to access the disk.

The adaptive aspect of the feature comes into play when the size of the hash table is adjusted based on changing workload patterns. When dataset characteristics change, the hash index will automatically adjust its size to optimize performance.

Benefits

The InnoDB Adaptive Hash Index provides several benefits, including:

  • Faster lookups: The hash index speeds up lookups by caching frequently accessed index pages in memory.
  • Reduced I/O requests: Since the frequently accessed pages are cached in memory, the number of disk I/O requests is reduced.
  • More efficient memory usage: The hash index adjusts its size in real-time, so it does not waste memory.
Configuration

InnoDB Adaptive Hash Index is enabled by default. However, it can be disabled or adjusted by changing the "innodb_adaptive_hash_index" system variable.

To disable adaptive hash index, set "innodb_adaptive_hash_index" to "0":

SET GLOBAL innodb_adaptive_hash_index = 0;

To adjust the size of the hash index, set "innodb_adaptive_hash_index_parts":

SET GLOBAL innodb_adaptive_hash_index_parts = 16;
Conclusion

The InnoDB Adaptive Hash Index is a powerful feature that provides faster lookups, reduced I/O requests, and efficient memory usage. It's worth enabling and adjusting the feature according to your workload patterns to optimize performance.