当前位置:网站首页>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
边栏推荐
- ESP32_ Arduino
- Questions about disaster recovery? Click here
- Spark 算子之sortBy使用
- GRBL学习(二)
- Merging of Shanzhai version [i]
- C#,贝尔数(Bell Number)的计算方法与源程序
- How to conduct application security test (AST)
- VIM uses vundle to install the code completion plug-in (youcompleteme)
- Day (8) of picking up matlab
- leetcode-374 猜数字大小
猜你喜欢
随机推荐
299. Number guessing game
捡起MATLAB的第(5)天
[open source tool sharing] MCU debugging assistant (oscillograph / modification / log) - linkscope
Day (9) of picking up matlab
Spark 算子之交集、并集、差集
Grbl learning (I)
Research and Practice on business system migration of a government cloud project
多线程原理和常用方法以及Thread和Runnable的区别
Function summary of drawing object arrangement in R language
C语言自编字符串处理函数——字符串分割、字符串填充等
vim指定行注释和解注释
捡起MATLAB的第(2)天
What is cloud migration? The four modes of cloud migration are?
捡起MATLAB的第(4)天
Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years
Compile, connect -- Notes
Using JSON server to create server requests locally
Read the meaning of serial port and various level signals
Named in pytoch_ parameters、named_ children、named_ Modules function
Leetcode-374 guess the size of the number