当前位置:网站首页>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 !
边栏推荐
- Every (), map (), forearch () methods. There are objects in the array
- NETRCA: AN EFFECTIVE NETWORK FAULT CAUSE LOCALIZATION之论文阅读
- 【Redis實現秒殺業務①】秒殺流程概述|基本業務實現
- eBanb B1手环刷固件异常中断处理
- A tip to read on Medium for free
- [noi simulation] pendulum (linear algebra, Du Jiao sieve)
- Easyexcel single sheet and multi sheet writing
- Kaformer personal notes
- 从618看京东即时零售的野心
- Data middle office: detailed explanation of technical architecture of data middle office
猜你喜欢
Depens:*** but it is not going to be installed

Linux (centos7.9) installation and deployment of MySQL Cluster 7.6
![[use picgo+ Tencent cloud object to store cos as a map bed]](/img/14/d650960cc77385504ea5e2e138bd46.jpg)
[use picgo+ Tencent cloud object to store cos as a map bed]

EasyExcel单sheet页与多sheet页写出
![[ES6 breakthrough] promise is comparable to native custom encapsulation (10000 words)](/img/b3/b156d75c7b4f03580c449f8499cd74.png)
[ES6 breakthrough] promise is comparable to native custom encapsulation (10000 words)

Squid代理服务器应用
![[e325: attention] VIM editing error](/img/58/1207dec27b3df7dde19d03e9195a53.png)
[e325: attention] VIM editing error

Spark - the number of leftouterjoin results is inconsistent with that of the left table

Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection

Numpy NP in numpy c_ And np r_ Explain in detail
随机推荐
Alibaba Senior Software Testing Engineer recommends testers to learn -- Introduction to security testing
小白学习MySQL - 增量统计SQL的需求
[redis realize Secondary killing Business ①] Overview of Secondary killing Process | Basic Business Realization
What do you mean by waiting for insurance records? Where should I go for filing?
每周推薦短視頻:談論“元宇宙”要有嚴肅認真的態度
支持向量机(SVC,NuSVC,LinearSVC)
1704. judge whether the two halves of a string are similar
P6698-[BalticOI 2020 Day2]病毒【AC自动机,dp,SPFA】
MYCAT read / write separation and MySQL master-slave synchronization
Depens:*** but it is not going to be installed
Microblog writing - flow chart - sequence chart - Gantt chart - Mermaid flow chart - good results
When programmers are asked if they can repair computers... | daily anecdotes
Data middle office: overview of data governance
Project deployment related
Tools
Linux (centos7.9) installation and deployment of MySQL Cluster 7.6
Easyexcel single sheet and multi sheet writing
Remote connection of raspberry pie without display by VNC viewer
怎么把mdf和ldf文件导入MySQL workbench中
牛客网 十进制整数转十六进制字符串