当前位置:网站首页>MySQL的btree索引和hash索引区别
MySQL的btree索引和hash索引区别
2022-04-23 16:07:00 【IT工作者】
在使用MySQL索引的时候, 选择b-tree还是hash
hash索引仅仅能满足"=","IN"和"<=>"查询,不能使用范围查询. 比如< , 由于 Hash 索引比较的是进行 Hash 运算之后的 Hash 值,所以它只能用于等值的过滤,不能用于基于范围的过滤,因为经过相应的 Hash 算法处理之后的 Hash 值的大小关系,并不能保证和Hash运算前完全一样
对于组合索引,Hash 索引在计算 Hash 值的时候是组合索引键合并后再一起计算 Hash 值,而不是单独计算 Hash 值,所以通过组合索引的前面一个或几个索引键进行查询的时候,Hash 索引也无法被利用
Hash 索引是将索引键通过 Hash 运算之后,将 Hash运算结果的 Hash 值和所对应的行指针信息存放于一个 Hash 表中,由于不同索引键存在相同 Hash 值,所以即使取满足某个 Hash 键值的数据的记录条数,也无法从 Hash 索引中直接完成查询,还是要通过访问表中的实际数据进行相应的比较,并得到相应的结果
Hash 索引遇到大量Hash值相等的情况后性能并不一定就会比B-Tree索引高。
B-Tree索引可以被用在像=,>,>=,<,<=和BETWEEN这些比较操作符上。而且还可以用于LIKE操作符,只要它的查询条件是一个不以通配符开头的常量
innodb和myisam存储引擎不能使用hash索引.........
版权声明
本文为[IT工作者]所创,转载请带上原文链接,感谢
https://cloud.tencent.com/developer/article/1986126
边栏推荐
- Day (10) of picking up matlab
- Spark 算子之sortBy使用
- Interview question 17.10 Main elements
- Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
- Metalife established a strategic partnership with ESTV and appointed its CEO Eric Yoon as a consultant
- VIM specifies the line comment and reconciliation comment
- Application case of GPS Beidou high precision satellite time synchronization system
- How important is the operation and maintenance process? I heard it can save 2 million a year?
- GRBL学习(二)
- GRBL学习(一)
猜你喜欢
随机推荐
Jour (9) de ramassage de MATLAB
JS regular determines whether the port path of the domain name or IP is correct
Meaning and usage of volatile
utils. Deprecated in35 may be cancelled due to upgrade. What should I do
ES常用查询、排序、聚合语句
糖尿病眼底病变综述概要记录
How to conduct application security test (AST)
Win11/10家庭版禁用Edge的inprivate浏览功能
Win11 / 10 home edition disables the edge's private browsing function
【现代电子装联期末复习要点】
Hypermotion cloud migration completes Alibaba cloud proprietary cloud product ecological integration certification
[section 5 if and for]
Website pressure measurement tools Apache AB, webbench, Apache jemeter
Spark 算子之distinct使用
Sortby use of spark operator
Distinct use of spark operator
Oak-d raspberry pie cloud project [with detailed code]
dlopen/dlsym/dlclose的简单用法
Read the meaning of serial port and various level signals
TIA博图——基本操作