当前位置:网站首页>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 .
边栏推荐
猜你喜欢
Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
Clock in during winter vacation
GTSAM中李群的运用
二维码的前世今生 与 六大测试点梳理
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
(中)苹果有开源,但又怎样呢?
【Postman】Monitors 监测API可定时周期运行
MPLS test report
【Postman】Collections-运行配置之导入数据文件
随机推荐
Commodity price visualization
公司視頻加速播放
在线问题与离线问题
VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator
Isam2 and incrementalfixedlagsmooth instructions in gtsam
win10无法操作(删除、剪切)文件
F - True Liars (种类并查集+DP)
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)
[C language] string left rotation
Manhattan distance and Manhattan rectangle - print back font matrix
异常检测方法总结
Introduction to promql of # yyds dry goods inventory # Prometheus
GTSAM中李群的运用
黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
Overview of three core areas of Mathematics: geometry
Eigen sparse matrix operation
功能安全之故障(fault),错误(error),失效(failure)
把el-tree选中的数组转换为数组对象