Comments (1)
谢谢,该原则我没有解释清楚,会立即更正。
最左前缀匹配原则:在mysql建立联合索引时会遵循最左前缀匹配的原则,即最左优先,在检索数据时从联合索引的最左边开始匹配。mysql会一直向右匹配直到遇到范围查询(>/</between/like)就停止匹配,比如a=3 and b=4 and c>5 and d=6,如果建立(a,b,c,d)联合索引,d就用不到索引,如果建立(a,b,d,c)则都能用到索引。
这里的 (name,age) 索引使用的不是最左前缀原则,而是索引下推
对于这条sql语句,使用到了最左前缀匹配原则,从name开始匹配,匹配到了name和age,才能使用到联合索引。我做过实验,改sql并没有使用索引下推。
索引下推的条件是使用Innodb的二级索引有并试图访问全表行的操作如范围查询。
最左前缀原则用于 name like 'A%'这样的查询,会使用到索引,加速查询
最左前缀原则不只用于like查询,具体规则在上面提到
from java-interview.
Related Issues (20)
- Java集合、多线程强化
- 分布式强化
- 进一步完善
- 支持楼主 HOT 1
- 算法题目和解法没对应上吧? HOT 1
- 在java 基础多线程篇中的最后一个奇偶打印的编程题 HOT 2
- 新增阿里面试点
- cannot load picture HOT 1
- todo
- todo
- JVM原理中对于对象逃逸的定义不对,并不是逃逸的对象无法被GC回收,那不就内存泄漏了
- 标记清除,标记整理算法描述有误,是标记存在引用链的对象,而不是标记要清理的对象 HOT 2
- 补充 HOT 3
- 二面补充 HOT 1
- 二面补充
- 二面补充
- Some suggestions HOT 2
- Redis强化
- 微服务部分简化
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-interview.