当前位置:网站首页>What happens when the MySQL union index ABC encounters a "comparison operator"?
What happens when the MySQL union index ABC encounters a "comparison operator"?
2022-06-13 05:47:00 【Coffee is not bitter**】
The last part tells about abc Joint index optimization , details :mysql How to optimize a federated index abc Use
This paper mainly studies the joint index abc Operator encountered “> or < or !=” What will happen? ?
List of articles
One 、 Data background
The index of this article is as follows :
Field corresponds to type and length as follows :
Two 、 When union index abc encounter “>” perhaps “<” Symbol
① a=a b Greater than or less than b c=c
explain select * from
employees
where uid=1 and last_name>“2” and first_name=“2”
The top link has a pair of ken_len Calculation method of , this explain,key_len=26
Let's calculate :uid by bigint type , So take 8 Bytes ;last_name and first_name by varchar, And because it's a letter , So it is n+2,last_name=16+2=16,first_name=14+2=16
If we calculate the sum, we can find , This situation only goes away a and b Indexes . How to optimize the index ? It must be changed to acb Chant . Of course, how to use indexes
② a=a b=b c Greater than or less than c
explain select * from
employees
where uid=1 and last_name=“2” and first_name>“2”
In this case, it is the full index .
③a Greater than or less than a b=b c=c
explain select * from
employees
where uid>1 and last_name=“2” and first_name=“2”
Index failed
3、 ... and 、 When union index abc encounter != Symbol
Encounter this symbol , Will it invalidate the entire index ? In the process of project development , In fact, the most used is in exists To realize relevant functions , Rumor has it that != Will invalidate the entire index , Let's test it and see :
①a=a b!=b c=c
explain select * from
employees
where uid=1 and last_name!=“2” and first_name=“2”
②a=a b=b c!=c
explain select * from
employees
where uid=1 and last_name=“2” and first_name!=“2”
③a!=a b=b c=c
explain select * from
employees
where uid!=1 and last_name=“2” and first_name=“2”
Look at the situation != Does not invalidate the entire index .
Four 、 summary
Encountered comparison operator , When abc Of a yes ><!= Three ways , Will invalidate the entire index , Other situations will only lead to partial index invalidation . In the daily development process , When creating an index, you should pay attention to .
边栏推荐
- MySQL advanced query
- SQL table columns and statements of database
- 890. Find and Replace Pattern
- 3. Postman easy to use
- Unity game optimization [Second Edition] learning record 6
- OpenGL mosaic (VIII)
- 2021.9.29学习日志-MIME类型
- Qmessagebox in pyqt5
- Tongweb crawl performance log script
- Deleted the jupyter notebook in the jupyter interface by mistake
猜你喜欢
Working principle of sentinel series (concept)
MySQL log management and master-slave replication
MySQL fuzzy query and sorting by matching degree
2021.9.30 learning log -postman
Sentinel series introduction to service flow restriction
Tongweb card, tongweb card, tongweb card
Solutions to conflicts between xampp and VMware port 443
890. Find and Replace Pattern
JS output uincode code
Database design
随机推荐
SQL table columns and statements of database
How slow is the application system on tongweb? How dead is it?
@Detailed explanation of propertysource usage method and operation principle mechanism
9. Errorstartevent and errorboundaryevent of error events
Unity游戏优化(第2版)学习记录7
Qmessagebox in pyqt5
Deleted the jupyter notebook in the jupyter interface by mistake
移动端适配方案
Difference between deviation and variance in deep learning
Four shardingsphere JDBC sharding strategies
Mongodb Multi - field Aggregation group by
若依框架=》如何设置导入导出模板全局为文本格式(解决科学计数问题)
Agile conflicts and benefits
NVIDIA Jetson Nano/Xavier NX 扩容教程
MySQL basic query
MySQL installation, architecture and management
Exception after repeated application redeployment on tongweb: application instance has been stopped already or outofmemoryerror:metaspace
Automatic database backup (using Navicat)
MySQL log management and master-slave replication
Unity game optimization (version 2) learning record 7