mysql InnoDB引擎支持hash索引吗
2017-08-19 20:33
573 查看
mysql InnoDB引擎支持hash索引吗
查一下mysql官方文档:https://dev.mysql.com/doc/refman/5.7/en/create-index.html,从上面的图中可以得知,mysql 是支持hash索引的,但支持和不支持又和具体的存储引擎有关系。从图中,
看到InnoDB是支持Btree索引,这是我们众所周知的。
我们具体查一下InnoDB文档那一部分:https://dev.mysql.com/doc/refman/5.7/en/innodb-introduction.html。
表中表明,InnoDB不支持hash索引,但又给出了一个特殊的解释,
InnoDB utilizes hash indexes internally for its Adaptive Hash Index
feature。
Performance benefits are not limited to giant tables with long-running queries. When the same rows are accessed over and over from a table, a feature called the Adaptive
Hash Index takes over to make these lookups even faster, as if they came out of a hash table.
adaptive hash index
An optimization for
InnoDBtables
that can speed up lookups using
=and
INoperators,
by constructing a hash index in
memory. MySQL monitors index searches for
InnoDBtables, and if queries could benefit from a hash index, it builds one automatically for index pages that
are frequently accessed. In a sense, the adaptive hash index configures MySQL at runtime to take advantage of ample main memory, coming closer to the architecture of main-memory databases. This feature is controlled by the
innodb_adaptive_hash_indexconfiguration
option. Because this feature benefits some workloads and not others, and the memory used for the hash index is reserved in the buffer
pool, typically you should benchmark with this feature both enabled and disabled.
The hash index is always built based on an existing
InnoDBsecondary
index, which is organized as a B-tree structure.
MySQL 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 against the index. A hash index can be partial; the whole B-tree index does not need to be cached in the buffer pool.
In MySQL 5.6 and higher, another way to take advantage of fast single-value lookups with
InnoDBtables is to use the
InnoDBmemcached plugin.
See Section 14.20,
“InnoDB memcached Plugin” for details.
See Also B-tree, buffer
pool, hash index, memcached, page, secondary
index.
看到了吗。mysqlInnoDB存储引擎 是支持hash索引的,不过,我们必须启用,hash索引的创建由InnoDB存储引擎引擎自动优化创建,我们干预不了。
其实【MySQL技术内幕InnoDB存储引擎.姜承尧.扫描版】也提到了这点,【对不起作者,一向喜欢看电子书,实体书实在买不起,因为电子书携带也比较方便,搬家也不用乱丢书了。】
所以,当有人问你mysql InnoDB存储引擎是否支持hash索引的时候,你知道怎么回答了吧。
相关文章推荐
- MySQL8.0的InnoDB和MyISAM是否支持hash索引
- MySQL8.0的InnoDB和MyISAM是否支持hash索引
- mysql中存储引擎为Innodb的索引介绍
- MySQL InnoDB引擎索引长度受限怎么办?
- SAE 免费配额用户 mysql 数据库 不支持InnoDB数据库引擎
- MySQL不支持InnoDB存储引擎解决方法
- 查看MySQL是否支持InnoDB引擎以及不支持的解决办法
- 让MySQL支持InnoDB存储引擎
- mysql innodb存储引擎的聚集索引
- Mysql innodb引擎和myisam引擎 使用索引区别
- 做一个合格的程序猿之MYSQL存储引擎INNODB简介--初识索引(三)
- mysql不支持innodb存储引擎
- MySQL技术内幕-InnoDB存储引擎读写笔记(索引概述)
- Mysql (InnoDB引擎)聚集索引和辅助索引
- 让MySQL支持InnoDB存储引擎的方法
- MySQL的InnoDB引擎的索引知识小结
- SAE 免费配额用户 mysql 数据库 不支持InnoDB数据库引擎 [更换博客转移文章]
- mysql的存储引擎innodb、myisam对插入影响和索引对插入的影响
- MySql中InnoDB引擎索引
- 让ubuntu10.04支持mysql的innodb引擎