当前位置:网站首页>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)
- IPv6 comprehensive experiment
- Clock in during winter vacation
- 全链路压测:构建三大模型
- Significance of unit testing
- How to use the container reflection method encapsulated by thinkphp5.1 in business code
- Arrays and collections
- 【微信小程序】搭建开发工具环境
- 公司视频加速播放
- The latest 2022 review of "graph classification research"
猜你喜欢
数据库隔离级别
Significance of unit testing
Seven imperceptible truths in software testing
D - How Many Answers Are Wrong
Arrays and collections
(5) Explanation of yolo-v3 core source code (3)
MySQL之数据类型
CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
Isam2 operation process
Application du Groupe Li dans gtsam
随机推荐
【Postman】测试(Tests)脚本编写和断言详解
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
公司视频加速播放
请求转发与重定向
Introduction to promql of # yyds dry goods inventory # Prometheus
Reading notes of effective managers
MySQL之数据类型
【Postman】动态变量(也称Mock函数)
全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法
GTSAM中李群的运用
Testing and debugging of multithreaded applications
CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
GTSAM中李群的運用
Réflexions sur la sécurité des données (réimpression)
[course notes] Compilation Principle
What are the test sites for tunnel engineering?
Summary of anomaly detection methods
Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
数据库-当前读与快照读
Amazon Engineer: eight important experiences I learned in my career