当前位置:网站首页>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 .
边栏推荐
- IDEA 新UI使用
- Company video accelerated playback
- 【Postman】Collections配置运行过程
- 10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
- [postman] collections - run the imported data file of the configuration
- win10无法操作(删除、剪切)文件
- LeetCode 739. 每日温度
- CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
- 异常检测方法总结
- Configuring OSPF GR features for Huawei devices
猜你喜欢

IPv6 comprehensive experiment

Fault, error, failure of functional safety

ESP32 ESP-IDF看门狗TWDT

功能安全之故障(fault),错误(error),失效(failure)

联合索引的左匹配原则
![Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)](/img/0a/054b994b29d4c50ede8b23514cf4ee.jpg)
Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)

数字三角形模型 AcWing 1015. 摘花生

Overview of three core areas of Mathematics: algebra

请求转发与重定向

D - How Many Answers Are Wrong
随机推荐
Redis 核心技术与实战之 基本架构:一个键值数据库包含什么?
Significance of unit testing
Seven imperceptible truths in software testing
【微信小程序】搭建开发工具环境
【LeetCode】Day96-第一个唯一字符&赎金信&字母异位词
Function of contenttype
ESP32 ESP-IDF看门狗TWDT
【C语言】qsort函数
Testing and debugging of multithreaded applications
Thoughts on data security (Reprint)
LeetCode 739. 每日温度
[postman] test script writing and assertion details
浅谈专项测试之弱网络测试
Postman核心功能解析-参数化和测试报告
「 WEB测试工程师 」岗位一面总结
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
IP day 16 VLAN MPLS configuration
【eolink】PC客户端安装
Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)
PAT(乙级)2022年夏季考试