当前位置:网站首页>Left matching principle of joint index
Left matching principle of joint index
2022-07-06 06:14:00 【Snow peak expensive】
Joint index :
key : ‘index_name_age’(‘name’,‘age’)
scene :
case1:
select * from person_info where name='gxf' and age = '18';
At this time, I will go index_name_age Joint index .
case2:
select * from person_info where name='gxf' ;
At this time, I will go index_name_age Joint index .
case3:
select * from person_info where age = '18';
here Not going index_name_age Joint index . Will scan the whole table .
Be careful
1. Left most prefix The matching principle
mysql Will match all the way to the right Until I met > 、< 、 between 、like Just stop matching .
where a=1 and b=2 and c=3 and d>4;
If set up index(a,b,d,c) be c There is no index .
If set up index(a,b,c,d) Are available to the index .
If set up index(b,c,a,d) Are available to the index .
2.= and in
You can order
If set up index(a,b,c,d).
where a=1 and b=2 and c=3 and d in(4,5);
where a=1 and d in(4,5) and b=2 and c=3 ;
All can be indexed , because mysql Will optimize your SQL Adjust the order to use the index .
Why? case3 Do not go through the joint index :

hypothesis : Now there is a joint index index(col3,col2);
be , There will be one stored in the joint index file B+ Trees , Leaf nodes store two Alice Row data , And on this basis , According to col2 Sort . final result :34 Of Alice It's in line 77 Of Alice In front of .
Now? where col3 = ‘Alice’ and col2=34; Then the leaf node will be found first , I'll find it again 34. That's the index .
if where col2 = 34; Then the joint index file is saved B+ The tree is useless . That is, you can't go through the index .
边栏推荐
- Eigen稀疏矩阵操作
- Detailed explanation of BF and KMP
- How to use the container reflection method encapsulated by thinkphp5.1 in business code
- PAT(乙级)2022年夏季考试
- selenium源码通读·9 |DesiredCapabilities类分析
- [ram IP] introduction and experiment of ram IP core
- ContentType的作用
- Introduction to promql of # yyds dry goods inventory # Prometheus
- [leetcode] day96 - the first unique character & ransom letter & letter ectopic word
- 数学三大核心领域概述:几何
猜你喜欢

Properties file
![[postman] test script writing and assertion details](/img/65/6520fe78bb2b3ff99f16d09ea8c0d1.png)
[postman] test script writing and assertion details
![[postman] the monitors monitoring API can run periodically](/img/9e/3f6150290b868fc1160b6b01d0857e.png)
[postman] the monitors monitoring API can run periodically

Arrays and collections

selenium源码通读·9 |DesiredCapabilities类分析

MySQL之数据类型

使用Nacos管理配置

PAT(乙级)2022年夏季考试
![[postman] collections configuration running process](/img/09/bcd9fd6379fa724671ffd09278442e.png)
[postman] collections configuration running process

Application of Lie group in gtsam
随机推荐
B - The Suspects
进程和线程的理解
Basic knowledge of error
D - How Many Answers Are Wrong
GTSAM中ISAM2和IncrementalFixedLagSmoother说明
【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
数学三大核心领域概述:几何
[postman] the monitors monitoring API can run periodically
联合索引的左匹配原则
Properties file
ContentType的作用
【eolink】PC客户端安装
Detailed explanation of BF and KMP
LeetCode 739. 每日温度
黑猫带你学UFS协议第4篇:UFS协议栈详解
LeetCode 731. 我的日程安排表 II
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Title 1093: character reverse order
Testing and debugging of multithreaded applications
公司視頻加速播放