当前位置:网站首页>MySQL 45 lecture learning notes (x) force index
MySQL 45 lecture learning notes (x) force index
2022-07-04 06:38:00 【Tom Kong】
One . Optimizer logic
Choose the index yes The job of the optimizer
The purpose of the optimizer's index selection :
- Find an optimal implementation plan , Execute the statement with the least cost
- The number of execution lines is one of the factors that affect the execution cost .
- The fewer lines to scan , It means that the fewer times you access disk data , Consume CPU The less resources .
The optimizer also combines Whether to use temporary table , Is it sorted? Other factors .
Two . How to judge the number of scanning lines
show index Method View index cardinality
MySQL Get the cardinality of the index
Sampling statistics :
- Take out the whole table and make statistics row by row , Although accurate results can be obtained, the cost is very high , Can only choose “ Sampling statistics ”
- InnoDB Default choice N Data pages , Count the different values on these pages , Get an average of , Then multiply by the number of pages in this index , Get index base .
- When the changed data exceeds 1/M It will automatically trigger an index statistics .
innodb_stats_persistent
Count disk or memory
- Set up on When , Statistics persistent storage
- Set up off When , Statistics of information in memory
analyze table t It can be used to count index information
Index selection exceptions and handling
Most of the time, the optimizer can find the correct index , But occasionally you will encounter the above situation :
- use force index Force an index
shortcoming :
- Programmers don't like to use force index, Index name changed , This statement needs to be changed .
advantage :
- Use force index The main problem is the timeliness of changes . Generally, when there is a problem online , Will modify SQL sentence , add force index. But after modification, it has to be tested and released . For production systems , This process is not agile enough .
2. Modify the statement , guide MySQL Use the index we expect
3. You can create a more suitable index , To provide the optimizer with choices , Or delete the misused index
边栏推荐
- 2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
- 17-18. Dependency scope and life cycle plug-ins
- leetcode 310. Minimum Height Trees
- Tree DP
- Redis面试题集
- tars源码分析之5
- 雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- Another company raised the price of SAIC Roewe new energy products from March 1
- [problem record] 03 connect to MySQL database prompt: 1040 too many connections
猜你喜欢
![[problem record] 03 connect to MySQL database prompt: 1040 too many connections](/img/bb/4d8d202cf5c6e556bc860a734e5934.png)
[problem record] 03 connect to MySQL database prompt: 1040 too many connections

雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)

Uniapp custom environment variables

树形dp

GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式

Arcpy uses the updatelayer function to change the symbol system of the layer

How to realize multi account login of video platform members

Native Cloud - SSH articles must be read on Cloud (used for Remote Login to Cloud Server)

Fundamentals of SQL database operation

Appium foundation - appium installation (II)
随机推荐
How to use multithreading to export excel under massive data? Source code attached!
雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
Invalid bound statement (not found): com. example. mapper. TblUserRecordMapper. login
Reading notes of Clickhouse principle analysis and Application Practice (4)
What is the sheji principle?
Vant --- detailed explanation and use of list component in vant
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
tars源码分析之9
SQL join, left join, right join usage
双色球案例
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
198. House raiding
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
Internet of things protocol ZigBee ZigBee module uses the concept of protocol stack
Another company raised the price of SAIC Roewe new energy products from March 1
C语言中的排序,实现从小到大的数字排序法
27-31. Dependency transitivity, principle
Practical gadget instructions
Tree DP