当前位置:网站首页>Explain tool actual operation
Explain tool actual operation
2022-07-27 03:26:00 【Hide on jdk】
new table :
CREATE TABLE `actor` (
`id` int(11) NOT NULL,
`name` varchar(45) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `film` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `film_actor` (
`id` int(11) NOT NULL,
`film_id` int(11) NOT NULL,
`actor_id` int(11) NOT NULL,
`remark` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_film_actor_id` (`film_id`,`actor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Let's take a look at the following sql:
select (select 1 from actor where id = 1) from (select * from film where id = 1) der;
1. It must be execution from Subsequent statements
2. In the execution of the inner layer select sentence
3. Execute the outer layer select sentence
We use it explain Look at the structure :
From this we can deduce :id The bigger it is, the earlier it is executed ,
Observe select_type:3. Is derived , That is, a temporary table 2 Is subquery 1. It is a primary key query
It can be seen that sql The order of execution is : From the back to the front

type Column
This column represents the association type or access type , namely MySQL Decide how to look up rows in the table , Find the approximate range of data row records . From the best to the worst are :system > const > eq_ref > ref > range > index > ALL
system What happened : There is only one record in the query derived table

const What happened :
The index has a primary key or a unique key

eq_ref: The primary key and index are connected

ref: The index is gone

range: The scope of the index

index: Scan the full index to get the results

ALL: Full table scan

key_len Column :
key_len The calculation rules are as follows :
char(n): If you save Chinese characters, the length is 3n byte
varchar(n): If you save Chinese characters, the length is 3n + 2 byte , Plus 2 Bytes are used to store string length , because
varchar Is a variable length string
value type
tinyint:1 byte
smallint:2 byte
int:4 byte
bigint:8 byte
Time type
date:3 byte
timestamp:4 byte
datetime:8 byte
If the field is allowed to be NULL, need 1 Is the byte record NULL

Why 140? 24*3+2+4+20*3+2=140
Why 4? Go, primary key , Other indexes do not take effect
10. Extra Column
Using where: Use where Statement to process the result , And the columns of the query are not covered by the index 
Using index: Use overlay index

Using index condition: The columns of the query are not completely covered by the index ,where In the condition is a leading range ;
Using filesort: Will use external sort instead of index sort , Sort data from memory when data is small , Otherwise, you need to finish sorting on disk 
Select tables optimized away
边栏推荐
- Byte side: can TCP and UDP use the same port?
- FactoryBean的getObject调用时机
- Mysql: summary of common sub database and sub table schemes of Internet companies
- 数据库概论 - MySQL的简单介绍
- Deeply understand the underlying data structure and algorithm of MySQL index
- 【树链剖分】2022杭电多校2 1001 Static Query on Tree
- Activiti5.22.0 extension supports domestic databases, taking gbase database as an example
- 客户端发送一条sql如何与服务器交互
- Spark Learning Notes (V) -- spark core core programming RDD conversion operator
- 深入理解Mysql索引底层数据结构与算法
猜你喜欢

spark学习笔记(四)——sparkcore核心编程-RDD

Take you to know what Web3.0 is

redis秒杀案例,跟着b站尚硅谷老师学习

$128million! IQM, a Finnish quantum computing company, was supported by the world fund

Post responsibilities of safety officer and environmental protection officer

be based on. NETCORE development blog project starblog - (16) some new functions (monitoring / statistics / configuration / initialization)

196. Delete duplicate email addresses
![[learn FPGA programming from scratch -54]: high level chapter - FPGA development based on IP core - principle and configuration of PLL PLL IP core (Altera)](/img/4f/f75cfeb4422120ef9ac70cdeb0a840.png)
[learn FPGA programming from scratch -54]: high level chapter - FPGA development based on IP core - principle and configuration of PLL PLL IP core (Altera)

flask_restful中reqparse解析器继承

vector 转 svg 方法
随机推荐
安全员及环保员岗位职责
196. Delete duplicate email addresses
AcWing 2074. 倒计数 模拟
185. All employees with the top three highest wages in the Department (mandatory)
数据库红的表如何设计才能使性能更加优化
flask_restful中reqparse解析器继承
Win10/win11 lossless expansion of C disk space, cross disk consolidation of C and e disks
最大连续子序列(DAY 77)
How to design the red table of database to optimize the performance
Boom 3D new 2022 audio enhancement app
Submodule cache cache failure
优炫数据库集群如何唯一标识一条用户SQL
Unity game, the simplest solution of privacy agreement! Just 3 lines of code! (Reprinted)
opiodr aborting process unknown ospid (21745) as a result of ORA-609
延时队列的几种实现姿势?日常必备技能!
Worthington过氧化物酶活性的6种测定方法
What are "full five unique" and "full two unique"? Any difference?
【flask】服务端获取客户端的请求头信息
mysql如何优化
$128million! IQM, a Finnish quantum computing company, was supported by the world fund