当前位置:网站首页>MySQL Explain usage and parameter detailed explanation
MySQL Explain usage and parameter detailed explanation
2022-07-30 09:32:00 【Li Bai loves tea】
The common performance bottlenecks of MySQL generally appear on the CPU and I/O, that is, when the data is loaded into the memory or read from the disk, the CPU is saturated or the loaded data is too large, and the memory capacity is insufficient.Disk I/O performance is limited.At this time, the Explain keyword is used for analysis and tuning.
Basic usage
Explain keyword can be used to simulate the optimizer to execute SQL query statement, so as to understand SQL statement processing method to achieve the performance bottleneck of analyzing query statement or table structure.
Available through Explain
- Table reading order and references
- Basic types of data read operations
- Available and actually used indexes
- Number of query rows for the optimizer
Parameter meaning
id
Indicates the sequence number of the select query, that is, the order in which the select statement or operation table is executed in the query. The id obtained from the query has two cases, which can exist at the same time
The id is the same, the execution order is from top to bottom

The id is different. If it is a subquery, the serial number of the id will increase. The larger the id value, the higher the priority and the earlier it will be executed

select_type
The type of query, which is mainly used to distinguish different queries such as common query, union query, sub query, etc.There are several ways
1. SIMPLE: A simple SELECT query without subqueries or UNION
2. PRIMARY: When the query contains complex queries such as subqueries, the outer query is marked as PRIMARY
3. SUBQUERY: Include subqueries in SELECT or WHERE
4. DERIVED: Subquery included in FROM
5. UNION: query after the keyword UNION
6. UNION RESULT: Query to get results from UNION table
table
Indicates which table the data is queried from and which tables are associated
partitions
Indicates which partition data is searched for
type
Indicates which type is used in the query, the specific types are
system: The table has only one row of records, which is equivalent to the system table. This is a special case of the const type and basically does not appear.
Const: It means that the matching data is found once through the index, such as querying by the conditions matching the primary key
eq_ref: Unique index scan, there is only one corresponding record in each index key table, that is, the case of primary key or unique index and their corresponding data
ref: Non-unique index scan, that is, indexFind out the data corresponding to multiple conditions
range: Only retrieve rows in a given range, and use an index to select rows, usually range queries such as between, <,>, in, etc.
index: read from the indexFetch the whole table
all: read the whole table from the hard disk, that is, read the whole data
Query efficiency: rank from good to bad
possible_keys
Indicates the index that may be used, usually if there is an index on the query field, it will be displayed, althoughnot necessarily used
key
The actual index used, if an overlay is used in the queryindex, the index will overlap with the select field of the query
key_len
The length of the index, the shorter the better, the value is a tableCalculate the estimated maximum length instead of the actual used length
ref
shows which column of the index is used
rows
Estimated number of rows to read to find matching data
Extra
Extra transactions are more important for analyzing retrieval efficiency, including the following:
Using filesort: MySQL uses an external index sort: "file sort", which means that the index order in the table cannot be used for reading
Using temporary: a temporary table is used, the information is usually used in sorting orAppears when grouping queries. MySQL uses temporary tables to store the query results that need to be sorted by order by and group by.Fetch data rows.Covering index: It is a new index based on the original index.
Using where: where filter is used. When using index appears at the same time, it means that the index is used to read the index key value, and the index key is the filter condition of where.
using join buffer: the connection cache is used.
impossible where: the value of the where clause is false and cannot be used to find data
select tables optimized away: Indicates that the index has optimized functions such as cont (*) in the query stage without group byOperation
distinct: Optimize the distinct operation, and stop searching for the same data after matching the first set of required data
边栏推荐
- 信号完整性测试
- 经典毕业设计:基于SSM实现高校后勤报修系统
- It is said that FPGA is high-end, what can it do?
- How to avoid CMDB becoming a data island?
- 嘉为鲸翼·多云管理平台荣获信通院可信云技术服务最佳实践
- 怎么在本地电脑上运行dist文件
- 瑞吉外卖项目(五) 菜品管理业务开发
- DDR、GDDR、QDR的区别
- How to implement Golang DES encryption and decryption?
- 【 HMS core 】 【 】 the FAQ HMS Toolkit collection of typical questions 1
猜你喜欢

XP电源维修fleXPower电源X7-2J2J2P-120018系列详解

详解JVM垃圾回收
![[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers](/img/ff/f3de4952d64afe36c515a2220bfe9d.png)
[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers

基于JSP实现校园二手交易平台

One article to understand twenty kinds of switching power supply topologies

leetcode力扣——一篇文章解决多数之和问题

Field interpretation under "Surgical variables (RX SUMM-SURG OTH REG/DIS)" in SEER database

如何使用 Jmeter 进行抢购、秒杀等场景下,进行高并发?

Circuit analysis: constant current source circuit composed of op amp and triode

ACL 2022 | Introduce angular margin to construct comparative learning objectives and enhance text semantic discrimination ability
随机推荐
Golang DES 加解密如何实现?
leetcode经典问题——11.盛水最多的容器
PyTorch安装及环境配置(Win10)
Windows 下安装 MySQL
MySQL [operator]
获取显示器数据
[Unity]UI切换环形滚动效果
The sword refers to offer 48: the longest non-repeating substring
编程界的“躲猫猫”比赛 | 每日趣闻
sort函数使用cmp出错Line 22: Char 38: error: reference to non-static member function must be called
新手必备!最全电路基础知识讲解
积分专题笔记-积分的定义
leetcode力扣——一篇文章解决多数之和问题
集合相关Collection
hcip 第14天学习笔记
Webview中的超链接点击到外部浏览器打开
基于SSM开发实现校园疫情防控管理系统
2022 Hangzhou Electric Multi-School 2nd Game
【无标题】
Reflection tricks can boost your performance by N times