当前位置:网站首页>[MySQL] index invalidation and index optimization
[MySQL] index invalidation and index optimization
2022-06-12 10:12:00 【Wang Rushuang】
List of articles
- 1. If the index column has more than one column , The leftmost prefix rule should be observed in the query criteria , That is, the query starts at the top left of the index and does not skip the columns in the index ; If this rule is not observed , The index will fail
- 2. Do anything on the index column ( Calculation , function , Automatic or manual type conversion ), It will cause index invalidation and turn to full table scan
- 3. A storage index cannot use the column to the right of the range condition in the index
- 4. Try to use overlay index , Reduce select * , This will only query the index fields , Improved efficiency using index
- 5. Use is not equal to != or <> It will lead to index invalidation and full table scanning
- 6.like Use wildcards % start (%abc...)mysql The index will fail, resulting in a full table scan
- 7. The query criteria include is null,is not null You can't use indexes
- 8. String index is invalid without single quotation marks ( Because the system automatically converts data types by default )
- 9.or The index fails when connecting
- 【 Index failure summary 】
- 【 Index optimization summary 】
| BTree How index works |
| Index failure |
1. If the index column has more than one column , The leftmost prefix rule should be observed in the query criteria , That is, the query starts at the top left of the index and does not skip the columns in the index ; If this rule is not observed , The index will fail

2. Do anything on the index column ( Calculation , function , Automatic or manual type conversion ), It will cause index invalidation and turn to full table scan

3. A storage index cannot use the column to the right of the range condition in the index

4. Try to use overlay index , Reduce select * , This will only query the index fields , Improved efficiency using index

5. Use is not equal to != or <> It will lead to index invalidation and full table scanning

6.like Use wildcards % start (%abc…)mysql The index will fail, resulting in a full table scan

But in the actual demand , There must be % The opening query , To meet this need , We can use overlay indexes , So it's solved ;
7. The query criteria include is null,is not null You can't use indexes

8. String index is invalid without single quotation marks ( Because the system automatically converts data types by default )
9.or The index fails when connecting

【 Index failure summary 】

| Index optimization |
- Single key index , Try to choose the current query Better filtering index
- Composite index , At present query The fields with the best filterability in the index field order can be placed as high as possible
- In combined query , Try to include the current query in where Index of more fields in clause
- Combination query join when : Reduce NestedLoop cycles , follow “ Always drive large result sets with small results ”; First, optimize the inner loop ; Guarantee join Statement on the driven table join The condition field has been indexed , The best situation is join All tables connected by are indexed ; When there is no guarantee that the driven meter join If the condition field is indexed and the memory resource is sufficient , Don't skimp JoinBuffer Set up
【 Index optimization summary 】

边栏推荐
- Enumerate all USB device codes
- 优质好书助成长 猿辅导携四大出版社推荐“暑期好书”
- 传输层协议 ——— TCP协议
- Basic use of scratch
- C# break continue return 三者区别
- IoT简介
- Papaya Mobile has a comprehensive layout of cross-border e-commerce SaaS papaya orange. What are the opportunities for this new track?
- [cloud native | kubernetes] kubernetes networkpolicy
- 2021-02-21
- MySQL优化之慢日志查询
猜你喜欢

MySQL index FAQs

Research progress of DNA digital information storage

7-13 地下迷宫探索(邻接表)

【云原生 | Kubernetes篇】Kubernetes 网络策略(NetworkPolicy)

How high can C language reach by self-study alone?

MYSQL的最左匹配原則的原理講解

True north reading notes

FPGA基于DE2-115平台的VGA显示

MySQL VI Database lock

Redis (I) Internal data structure
随机推荐
[path of system analyst] Chapter 18 security analysis and design of double disk system
1268_ Implementation of FreeRTOS task context switching
Introduction to on-line circuit simulation and open source electronic hardware design
Combat tactics based on CEPH object storage
JVM (VIII) Thread safety and lock optimization
[926. flip the string to monotonic increment]
redis学习记录:字典(dict)源码分析
one
链式哈希表
在App内跳转微信,打开微信
MySQL 4 Database table storage structure & tablespace
Access and traversal of string class objects
tp6调试(trace)
用于图像处理的高性能计算框架
7-5 哲哲打游戏
004:aws data Lake solution
C language recursive folder code
SAP Hana error message sys_ XSA authentication failed SQLSTATE - 28000
C break continue return
在线电路仿真以及开源电子硬件设计介绍