当前位置:网站首页>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
边栏推荐
- 【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
- Distributed cap theory
- Native Cloud - SSH articles must be read on Cloud (used for Remote Login to Cloud Server)
- 微信小程序使用rich-text中图片宽度超出问题
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- 如何实现视频平台会员多账号登录
- Reading notes of Clickhouse principle analysis and Application Practice (4)
- How does the recv of TCP socket receive messages of specified length?
- Tar source code analysis Part 2
- Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
猜你喜欢

【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)

R statistical mapping - random forest classification analysis and species abundance difference test combination diagram
![[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)](/img/03/2b37e63d0d482d5020b7421ac974cb.jpg)
[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)

Matlab remainder

C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing

校园网络问题

Fundamentals of SQL database operation

C réaliser des jeux de serpents gourmands

Sleep quality today 78 points

《ClickHouse原理解析与应用实践》读书笔记(4)
随机推荐
Common usage of time library
Reading notes of Clickhouse principle analysis and Application Practice (4)
期末周,我裂开
How to use multithreading to export excel under massive data? Source code attached!
What is the "relative dilemma" in cognitive fallacy?
Abap:ooalv realizes the function of adding, deleting, modifying and checking
Vant --- detailed explanation and use of list component in vant
ABAP:OOALV实现增删改查功能
Variables d'environnement personnalisées uniapp
[backpack DP] backpack problem
ABCD four sequential execution methods, extended application
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
tars源码分析之10
内卷怎么破?
How does the inner roll break?
2022.7.2-----leetcode. eight hundred and seventy-one
《国民经济行业分类GB/T 4754—2017》官网下载地址
leetcode 310. Minimum Height Trees