当前位置:网站首页>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
边栏推荐
- Start Oracle service on Linux
- 王启亨谈Web3.0与价值互联网“通证交换”
- 一文掌握vscode远程gdb调试
- The principle and common methods of multithreading and the difference between thread and runnable
- pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
- New developments: new trends in cooperation between smartmesh and meshbox
- Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years
- Review 2021: how to help customers clear the obstacles in the last mile of going to the cloud?
- 安装Redis并部署Redis高可用集群
- Upgrade MySQL 5.1 to 5.610
猜你喜欢
随机推荐
Es common query, sorting and aggregation statements
撿起MATLAB的第(9)天
Hyperbdr cloud disaster recovery v3 Release of version 3.0 | upgrade of disaster recovery function and optimization of resource group management function
matplotlib教程05---操作图像
Coalesce and repartition of spark operators
JVM - Chapter 2 - class loader subsystem
Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years
Research and Practice on business system migration of a government cloud project
ES常用查询、排序、聚合语句
运维流程有多重要,听说一年能省下200万?
Day (9) of picking up matlab
糖尿病眼底病变综述概要记录
VIM specifies the line comment and reconciliation comment
C language self compiled string processing function - string segmentation, string filling, etc
utils. Deprecated in35 may be cancelled due to upgrade. What should I do
面试题 17.10. 主要元素
Upgrade MySQL 5.1 to 5.610
一文掌握vscode远程gdb调试
linux上啟動oracle服務
js正則判斷域名或者IP的端口路徑是否正確