当前位置:网站首页>MySQL performance analysis - explain
MySQL performance analysis - explain
2022-06-13 00:59:00 【-LM-】
Explain
explain+SQL sentence
What do you do
- Read order of tables
- Operation type of data read operation
- Which indexes can be used
- Which indexes are actually used
- References between tables
- How many rows per table are queried by the optimizer
id*
select The serial number of the query , Contains a set of numbers , Represents execution in a query select The order of clauses or operation tables
Three situations
- id identical , Execution order from top to bottom
- id Different , If it's a subquery ,id The serial number is incremented ,id The higher the value, the higher the priority , The first to be executed
- id Same and different , At the same time .id If the same , It can be thought of as a group , From top to bottom ; In all groups ,id The bigger the value is. , The higher the priority , Execute first .
select_type
Common values :
- SIMPLE : ordinary select Inquire about , The query does not contain subqueries or UNION
- PRIMARY: If the query contains any complex Sub part , Outermost query marked
- SUBQUERY: stay select or where The list contains subqueries
- DERIVED: stay FROM The subqueries contained in the list are marked as derived ,MySQL These subqueries will be executed recursively , Put the results on the provisional list .
- UNION: If the second SELECT Appear in the UNION after , Is marked as UNION; if UNION Included in FROM Clause , Outer layer SELECT Will be marked as DERIVED
- UNION RESULT: from UNION Get the result in the table SELECT
Type of query , It is mainly used to distinguish ordinary queries , The joint query , Complex queries such as subqueries
table
Show which table this row's data is about
type*
- ALL: Read from the hard disk , Full table scan , The worst
- INDEX:index Type only traverses the index tree , Often than ALL fast , Because index files are usually smaller than data files
- RANGE: Retrieve only rows in the given range , Use an index to select rows ,key Column shows which index is used . It's usually in your where In the sentence between、<、>、in And so on , This range scan index scan is better than full table scan , Because it only needs to start with a certain point of the index , And end at another point , Don't scan all indexes .
- REF: Non unique index scan , Returns all rows that match a single value , In essence, it is also an index access , It returns all rows that match a single value , However, it may find more than one eligible row , So it should be a mixture of search and scan
- EQ_REF: Unique index scan , Build... For each index , Only one record in the table matches it , Common in primary key or unique index scanning
- CONST: Indicates that it is found through index once ,const For comparison primary key perhaps unique Indexes , Because only one line of data is matched , So soon . For example, place the primary key in where In the list ,MySQL You can convert the query to a constant
- SYSTEM: There is only one line in the table ( It's equal to the system table ), This is a const Special case of type , Not usually
- NULL
From the best to the worst is system>const>eq_ref>ref>range>index>all
possible_keys
Show the indexes that may be applied to this table , One or more .
If there is an index on the field involved in the query , Then the index will be listed , But it doesn't have to be actually used by the query
key*
Actual index used , If NULL, No index is used
If an overlay index is used in the query , The index appears only in key In the list
key_len
Represents the number of bytes used in the index , You can use this column to calculate the length of the index used in the query , Without losing accuracy , The shorter the length, the better .key_len The displayed value is the maximum possible length of the index field , It's not the actual length , namely key_len It is calculated according to the table definition , It is not retrieved from the table .
ref
Shows which column of the index is used , If possible , It's a constant . Which columns or constants are used to find values on index columns .
rows*
According to table statistics and index selection , Roughly estimate the number of rows to read to find the required record
Extra*
Contains additional information that is not suitable for display in other columns but is important
- Using filesort : explain mysql Will use an external index to sort the data , Instead of reading in the order of the indexes in the table .MySQL The sort operations that can't be done with indexes in are called “ File sorting ”
- Using temporary : Use temporary table to save intermediate results ,MySQL Use temporary tables when sorting query results . It is common in sorting order by And group queries group by.
- USING index: It means corresponding select The override index is used in the operation (Covering Index), Avoid accessing the data rows of the table , Good efficiency ! If it appears at the same time using where, Indicates that the index is used to perform index key value lookups ; If not at the same time using where, Indicates that the index is only used to read data and not to perform searches using the index . Overlay index (Covering Index)
- Using where: Indicates that where Filter
- using join buffer: Connection caching is used
- impossible where:where The value of the clause is always false, Can't be used to get any tuples
- select tables optimized away: In the absence of GROUPBY In the case of clause , Index based optimization MIN/MAX Operation or for MyISAM Storage engine optimization COUNT(*) operation , You don't have to wait until the execution phase to do the calculation , The query execution plan generation phase completes the optimization .
边栏推荐
- Antdpro - protable realizes the linkage effect of two selection boxes
- redis
- [Latex] 插入图片
- 人神共愤,唐山“群殴女性事件”细节...
- [JS component] previous queue prompt
- OceanBase 雄踞墨天轮2021年度中国数据库魔力象限领导者
- Et5.0 value type generation
- How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of DBCD, ROC, vroc, Cr and psy index strategy income
- Oceanbase is the leader in the magic quadrant of China's database in 2021
- Today's sleep quality record 74 points
猜你喜欢

Influence of higher order poles on waveform

Opencv desaturation

今日睡眠质量记录74分

Cards are unpredictable

How many steps are appropriate for each cycle of deep learning?

Download nail live playback through packet capturing

数学知识整理:极值&最值,驻点,拉格朗日乘子

. The way to prove the effect of throwing exceptions on performance in. Net core

Kotlin 协程的作用域构建器 coroutineScope与runBlocking 与supervisorScope,协程同步运行,协程挂掉的时候其他协程如何不被挂掉。

Undirected graph -- computing the degree of a node in compressed storage
随机推荐
MCU serial port interrupt and message receiving and sending processing -- judge and control the received information
Illustrator tutorial, how to add dashes and arrows in illustrator?
How to solve the duplication problem when MySQL inserts data in batches?
Zhouchuankai, Bank of Tianjin: from 0 to 1, my experience in implementing distributed databases
About_ int128
【服务器数据恢复】存储服务器之间迁移数据时数据丢失恢复成功案例
[North Asia server data recovery] data recovery case of Hyper-V service paralysis caused by virtual machine file loss
Three column simple Typecho theme lanstar/ Blue Star Typecho theme
牌好不好无法预料
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic benefits of ASI, VR, arbr, DPO and trix indicators
Unity extension
Binary tree - right view
Canvas game lower level 100
What is the difference between pytorch and tensorflow?
Remove duplicates from an ordered array
[JS] solve the problem that removeeventlistener is invalid after the class listening event from new is bound to this
gpu加速pytorch能用吗?
[network protocol] problems and solutions in the use of LwIP
spiral matrix visit Search a 2D Matrix
[JS component] create a custom horizontal and vertical scroll bar following the steam style