当前位置:网站首页>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
边栏推荐
- 分布式CAP理论
- Mysql 45讲学习笔记(十一)字符串字段怎么加索引
- 微信小程序使用rich-text中图片宽度超出问题
- [MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)
- JSON web token -- comparison between JWT and traditional session login authentication
- CORS is not intended to protect API endpoints - nikofischer
- Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?
- Displaying currency in Indian numbering format
- Average two numbers
- What is the "relative dilemma" in cognitive fallacy?
猜你喜欢

Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?

Arcpy 利用updatelayer函数改变图层的符号系统

4G wireless all network solar hydrological equipment power monitoring system bms110

P26-P34 third_ template

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

JSON web token -- comparison between JWT and traditional session login authentication

C language exercises (recursion)

746. Climb stairs with minimum cost

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

Learning multi-level structural information for small organ segmentation
随机推荐
Bicolor case
leetcode825. 适龄的朋友
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
Tree DP
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
tars源码分析之1
SQL join, left join, right join usage
How to use multithreading to export excel under massive data? Source code attached!
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Software keywords and process information intercepted by Golden Shield video player
tars源码分析之10
leetcode 310. Minimum Height Trees
《ClickHouse原理解析与应用实践》读书笔记(4)
内卷怎么破?
Functions in C language (detailed explanation)
Invalid bound statement (not found): com. example. mapper. TblUserRecordMapper. login
[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
What is the "relative dilemma" in cognitive fallacy?
Common JS tool Libraries