当前位置:网站首页>L01_ How is an SQL query executed?
L01_ How is an SQL query executed?
2022-06-24 09:15:00 【jackaroo2020】
Reading guide
This article mainly adopts a SQL Query statement , Let's have a preliminary understanding of MYSQL Basic framework .

1、MYSQL Logical architecture
mysql> select * from T where ID=10;
Here is MySQL Basic architecture diagram , You can see clearly from it SQL Statements in MySQL The execution process in each function module of .

2、MySQL The framework has several components , What is the role of each ?
The connector
Responsible for and mysql The client establishes a connection , Get user rights , Maintaining and managing connections . The connection command is usually written like this :
mysql>mysql -h$ip -P$port -u$user -p
When the connection is complete , If you don't follow up , This connection is idle , You can show processlist See it in the command . As shown in the figure , Among them Command The column is shown as “Sleep” This line , It means that there is an idle connection in the system . If the client does not move for a long time , The connector will automatically disconnect it . This time is determined by the parameter wait_timeout The control of the , The default value is 8 Hours . The order is :
mysql>show processlist;
mysql>show variables like 'wait_timeout';

The query cache
Query requests to access the cache first (key Is the statement of the query ,value Is the result of a query ). Hit direct return . Caching is not recommended , Updates will clear the cache ( Turn off caching : Parameters query_cache_type Set to DEMAND). For the statements that you decide to use the query cache , It can be used SQL_CACHE Explicitly specify , Like the following statement :
mysql>select SQL_CACHE * from T where ID=10;
It should be noted that ,MySQL 8.0 Version of the query cache directly removed the entire block , in other words 8.0 It's starting to disappear completely .
analyzer
analysis sql Statement for errors , Lexical analysis and grammatical analysis .
Optimizer
Decide which index to use , More than a table (join) When , Determine the join order of the tables .
actuator
Execute statement , First judge whether the user has query permission , Storage engine using table definitions .
mysql> select * from T where ID=10;
For example, the table in our example T in ,ID Field has no index , So the execution process of the actuator is like this :
(1) call InnoDB The engine interface takes the first row of this table , Judge ID Value is 10, If not, skip , If it is, the row will exist in the result set ;
(2) Call the engine interface “ The next line ”, Repeat the same logic of judgment , Until you get to the last row of the table .
(3) The executor returns the record set composed of all the rows that meet the conditions in the traversal process to the client as a result set .
3、Server What are the roles of the storage engine layer and the storage engine layer ?
In general ,MySQL Can be divided into Server Layer and storage engine layer .
Server layer Including connectors 、 The query cache 、 analyzer 、 Optimizer 、 Actuators etc. , cover MySQL Most of the core service functions of , And all the built-in functions ( Such as date 、 Time 、 Mathematics and cryptographic functions ), All cross-storage engine functionality is implemented in this layer , Like stored procedures 、 trigger 、 View etc. .
Storage engine layer Responsible for data storage and extraction . Its architecture pattern is plug-in , Support InnoDB、MyISAM、Memory Wait for multiple storage engines . Now the most commonly used storage engine is InnoDB, It is from MySQL 5.5.5 Version began to be the default storage engine .
The notes are mainly from teacher linxiaobin <<MYSQL actual combat 45 speak >> Course , It is mainly used for personal learning notes , If this article infringes upon your rights , Please contact me , I will delete the infringing articles as soon as possible !
边栏推荐
- 深入解析 Apache BookKeeper 系列:第三篇——读取原理
- [noi Simulation Competition] send (tree DP)
- Target detection series fast r-cnn
- Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection
- Essay - Reflection
- Time Series Data Augmentation for Deep Learning: A Survey 之论文阅读
- Kaformer personal notes
- Pytorch读入据集(典型数据集及自定义数据集两种模式)
- MySQL - SQL statement
- Recommendation - Secret of curiosity: how many dancing angels can stand on the tip of a needle?
猜你喜欢
![[redis implements seckill business ①] seckill process overview | basic business implementation](/img/a3/9a50e83ece43904a3a622dcdb05b3c.png)
[redis implements seckill business ①] seckill process overview | basic business implementation
Depens:*** but it is not going to be installed

Redis implements a globally unique ID

【Redis實現秒殺業務①】秒殺流程概述|基本業務實現

The native applet uses canvas to make posters, which are scaled to the same scale. It is similar to the uniapp, but the writing method is a little different

Huawei Router: GRE Technology

Epidemic situation, unemployment, 2022, we shouted to lie down!

【bug】@JsonFormat 使用时出现日期少一天的问题

【Redis实现秒杀业务①】秒杀流程概述|基本业务实现

解决:jmeter5.5在win11下界面上的字特别小
随机推荐
MySQL - SQL statement
【Redis实现秒杀业务①】秒杀流程概述|基本业务实现
leetcode——错误的集合
"I can't understand Sudoku, so I choose to play Sudoku."
Xiaobai needs to learn MySQL - incremental statistical SQL
CF566E-Restoring Map【bitset】
MySQL | view notes on Master Kong MySQL from introduction to advanced
Easyexcel single sheet and multi sheet writing
Remote connection of raspberry pie without display by VNC viewer
浮点数表示法(总结自CS61C和CMU CSAPP)
Support vector machine (SVC, nusvc, linearsvc)
eBanb B1手环刷固件异常中断处理
[redis realize Secondary killing Business ①] Overview of Secondary killing Process | Basic Business Realization
牛客网 实现简单计算器功能
1528. rearrange strings
学习太极创客 — ESP8226 (十二)ESP8266 多任务处理
支持向量机(SVC,NuSVC,LinearSVC)
YOLOX backbone——CSPDarknet的实现
I heard that you are still spending money to buy ppt templates from the Internet?
陆奇:我现在最看好这四大技术趋势