【MySQL 5.7 Reference Manual】15.4.3 Adaptive Hash Index(自适应哈希索引)

翻译 2017年01月02日 21:23:42
15.4.3 Adaptive Hash Index(自适应哈希索引)

The adaptive hash index (AHI) lets InnoDB perform more like an in-memory database on systems with appropriate combinations of workload and ample memory for the buffer pool, without sacrificing any transactional features or reliability. This feature is enabled by the innodb_adaptive_hash_index option, or turned off by --skip-innodb_adaptive_hash_index at server startup.

自适应哈希索引(AHI)使InnoDB平台看起来更像一个内存数据库(在系统负载适当并且分配给缓存池的内存充裕的情况下),且不牺牲任何事务特性或可靠性。这个特性可以在服务启动时通过innodb_adaptive_hash_index选项生效,或者通过--skip-innodb_adaptive_hash_index关闭。

Based on the observed pattern of searches, MySQL builds a hash index using a prefix of the index key. The prefix of the key can be any length, and it may be that only some of the values in the B-tree appear in the hash index. Hash indexes are built on demand for those pages of the index that are often accessed.

根据所观察到的的搜索模式,MySQL用一个索引键的前缀建立一个哈希索引。该键的前缀可以是任意长度,并且只有B-tree中的少数值才会出现在哈希索引中。哈希索引是为了获取那些被频繁访问的索引页而建立的。

If a table fits almost entirely in main memory, a hash index can speed 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.

如果一张表几乎整个被至于主内存中,那么有了哈希索引就可以直接查找任意元素并将其索引值转换为一系列的指针从而提升查询速度。InnoDB有一个机制可以监控索引的搜索。如果InnoDB注意到查询可以通过建立哈希索引得到优化,那么他就会自动做这件事。

With some workloads, the speedup from hash index lookups greatly outweighs the extra work to monitor index lookups and maintain the hash index structure. Sometimes, the read/write lock that guards access to the adaptive hash index can become a source of contention under heavy workloads, such as multiple concurrent joins. Queries with LIKE operators and % wildcards also tend not to benefit from the AHI. For workloads where the adaptive hash index is not needed, turning it off reduces unnecessary performance overhead. Because it is difficult to predict in advance whether this feature is appropriate for a particular system, consider running benchmarks with it both enabled and disabled, using a realistic workload. The architectural changes in MySQL 5.6 and higher make more workloads suitable for disabling the adaptive hash index than in earlier releases, although it is still enabled by default.

只需增加少量负载,这种由于哈希索引查询所带来的速度提升大大超过监控索引查询和维护哈希索引结构的所带来的额外工作量。有时,在高负载的情况下守护自适应哈希索引访问的读写锁会变成一种竞争资源,例如多重并发关联。基于LIKE操作和%通配符的查询也往往不通过AHI来优化。对于自适应哈希索引所不需要的负载,关闭它以节省不必要的性能开销。由于难以提前预测该特性是否适用于某一特定系统,需要在实际负载下,识别在其启用和禁用时的运行指标。该架构在MySQL 5.6及以上版本中改变,相比之前的版本,禁用自适应哈希索引会适当的产生更多的负载。

As of MySQL 5.7.8, the adaptive hash index search system 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 configuration option. Prior to MySQL 5.7.8, the adaptive hash index search system was protected by a single latch which could become a point of contention under heavy workloads. The innodb_adaptive_hash_index_parts option is set to 8 by default. The maximum setting is 512.

从MySQL 5.7.8开始,自适应哈希索引搜索系统是分区的。每个索引都会绑定到一个特殊的分区上,并且每个分区都由各自独立的锁存器来保护。分区受到innodb_adaptive_hash_index_parts配置项的控制。在MySQL5.7.8之前,自适应哈希索引搜索系统是通过一个单独的锁存器来保护,在高负载的情况下它会变成竞争点。innodb_adaptive_hash_index_parts选项默认值为8,最大值为512。

The hash index is always built based on an existing B-tree index on the table. InnoDB can build a hash index on a prefix of any length of the key defined for the B-tree, depending on the pattern of searches that InnoDB observes for the B-tree index. A hash index can be partial, covering only those pages of the index that are often accessed.

哈希索引的建立总是基于表上的一个现有的B-tree索引。InnoDB可以用任意长度的B-tree键的前缀建索引,依赖于InnoDB从B-tree索引上所观察到的搜索模式。哈希索引可以是局部的,仅覆盖哪些经常被访问的索引页。

You can monitor the use of the adaptive hash index and the contention for its use in the SEMAPHORES section of the output of the SHOW ENGINE INNODB STATUS command. If you see many threads waiting on an RW-latch created in btr0sea.c, then it might be useful to disable adaptive hash indexing.

你可以通过SHOW ENGINE INNODB STATUS命令所输出的SEMAPHORES部分来监控自适应哈希索引的使用及其竞争情况。如果你看到许多线程正在等待一个在btr0sea.c中创建的RW-latch,然后它可能被用于禁用自适应哈希索引。

For more information about the performance characteristics of hash indexes, see Section 9.3.8, “Comparison of B-Tree and Hash Indexes”.

更多信息关于哈希索引的性能特性,请参考9.3.8,“B-Tree和哈希索引的竞争”。

相关文章推荐

理解innodb的索引页结构,插入缓冲,自适应哈希索引

Physical Structure of an InnoDB Index 所有的innodb索引都是btree索引,索引记录保存在叶子上,默认的索引页大小是16K。当有新的记录插入时,innodb...

InnoDB存储引擎——自适应哈希索引

自适应哈希索引(Adaptive Hash Index, AHI)

JAVA启动参数大全之一:标准参数

前段时间系统升级时遭遇了OOM,具体解决过程见 遭遇OutOfMemoryError;为了巩固对于java启动各项参数的认识,决定将所有参数列举出来,并一一解释,以便后查;java启动参数共分为三类;...
  • sfdev
  • sfdev
  • 2008年01月23日 21:29
  • 13543

C# winform程序免安装.net framework在XP/win7/win10环境运行!

首先感谢群里的大神宇内流云 提供的anyexec for windows版本。 经过本人搭建虚拟机在xp环境 使用anyexec运行winfrom程序后,测试通过,如下是用的xp运行winfro...
  • nic7968
  • nic7968
  • 2017年03月21日 11:48
  • 413

【MySQL 5.7 Reference Manual】15.4.7 Doublewrite Buffer(双写缓冲)

双写缓冲是一个位于系统表空间中的存储区域,InnoDB缓冲池中刷出的页在被写入数据文件的适当位置之前会先写入这里。只有把页刷出并写入到双写缓冲之后,InnoDB才会把页写入到适当位置。假如此时操作系统...

MySQL 5.7 Reference Manual Chapter 4 Tutorial 参考手册第四章教程内容总结

MySQL 5.7 Reference Manual Chapter 4 Tutorial 参考手册第四章教程内容总结

【MySQL 5.7 Reference Manual】15.4.2 Change Buffer(变更缓冲)

变更缓冲是一个特殊的数据结构,当目标页不在缓冲池中时,变更缓冲负责缓存对二级索引页的变更。被缓冲的变更内容可能是INSERT,UPDATE,或DELETE操作(DML)的结果。在下一次读操作时这些页会...

【MySQL 5.7 Reference Manual】15.4.12.1 InnoDB Temporary Table Undo Logs(InnoDB临时表Undo日志)

临时表undo日志,在MySQL 5.7.2中被引入,用于存放临时表和相关对象。这种类型的undo日志不是一个redo日志,因为临时表在崩溃恢复期间不会被恢复并且不需要redo日志。然而,临时表und...

【MySQL 5.7 Reference Manual】15.4.13 Redo Log(Redo日志)

redo日志基于磁盘的数据结构,在崩溃恢复期间用于纠正不完整事务所写入的数据。在正常操作情况下,redo日志编码请求以改变InnoDB表数据,这些数据来自于SQL语句或低级API调用的结果。如果在意外...

MySQL 5.7 Reference Manual Chapter 13 Functions and Operators 参考手册第十三章函数与操作符内容总结

MySQL 5.7 Reference Manual Chapter 13 Functions and Operators 参考手册第十三章函数与操作符内容总结...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:【MySQL 5.7 Reference Manual】15.4.3 Adaptive Hash Index(自适应哈希索引)
举报原因:
原因补充:

(最多只允许输入30个字)