当前位置:网站首页>Analysis -- MySQL statement execution process & MySQL architecture
Analysis -- MySQL statement execution process & MySQL architecture
2022-07-07 05:00:00 【Certainly tomorrow】
Catalog
Manage service components and tool components
Statement execution procedure
- Establishing a connection . Through the client / The server communication protocol establishes a connection , The mode of communication is Half duplex . The established connection has a thread monitoring status , We can use show processlist; To view the . The detailed field meaning can be determined by Baidu .
- The query cache . If the exact query is matched in the cache sql, Then directly return the data in the cache . have access to show variables like '%query_cache%'; Check whether query caching is enabled 、 Cache size 、 Limit etc.
have access to show status like 'Qcache%'; See more detailed cache parameters , Available cache space , Cache block .
- Parser . analysis sql, Preprocessing . For example, check sql grammar 、 Check if the list exists 、 The analysis shows that , Table alias . Then generate the parse tree .
- Query optimizer . Generate the optimal execution plan according to the parse tree . It can be divided into compile time optimization and run-time optimization .
- Query execution engine . Responsible for the execution of sql, According to the storage engine , And corresponding api Interface or physical file interaction , Find the result and return it to the client . If the cache is enabled , Will sql Statements and results are cached . If too many results are returned , Then take incremental return to reduce pressure .
The general flow chart is as follows :
What is half duplex
Data is usually in two stations ( Point to point ) Transmission between , According to the direction of data flow, it can be divided into three transmission modes : Simplex 、 Half duplex , full duplex .
Simplex : Only send or receive . A one-way street similar to a road .
Half duplex : At the same time , Only send or accept . Similar to the previous interphone .
full duplex : Send and receive at any time . It's like making a phone call .
framework
It is roughly divided into four layers : Network connection layer 、 Service layer 、 Storage engine layer 、 System file layer .
Network connection layer
mysql Support the mainstream programming technology of the server . The essence is still through tcp The protocol establishes the connection .
Service layer
Thread pool
MySQL Is a single process multithreaded application , When the user passes Connetor towards MySQL Server When requesting a connection , Through the thread pool (Connection Pool) Establish a user connection , This connection session will always exist .
sql Interface
Accept sql sentence
Parser
Conduct sql analysis , Generate parse tree
Optimizer
Optimize the parse tree . Analyze and measure the cost of which method , Minimum cost , The cost calculation depends on the various internal components of the index to evaluate , The result is an approximation , Also consider the current MySQL Statistics of internal resource access
cache
If you turn on caching , Will query sql And full result cache .
When inquiring , If cache hits , Then go to cache to find .
Manage service components and tool components
Backup & Recovery: Backup recovery tools Security: Safety tools Replication: Copy tool Cluster: The cluster service Administration Configuration: Manage configuration tools Migration: Migration tools Metadata: Responsible for managing the MySQL Metadata tools
Storage engine layer
Pluggable storage engine . You can specify the storage engine when creating tables .
System file layer
Log files . Error log 、 General query log 、 Binary log 、 Slow query log
Data files .
The configuration file .mysql Configuration information file .
pid file .unix perhaps Linux Delegate your own processes id.
socket file . use unix socket Connect mysql.
The above is an explanation of the infrastructure process , You can expand on this basis , For example, how the storage engine modifies data …… There are too many extensible points , If you want to study deeply, you still need some time and energy .
边栏推荐
- Windows are not cheap things
- Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
- 九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
- Comparison between thread and runnable in creating threads
- JS input and output
- 食堂用户菜品关系系统(C语言课设)
- A detailed explanation of head pose estimation [collect good articles]
- Analyse approfondie de kubebuilder
- IMS data channel concept of 5g vonr+
- 九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
猜你喜欢
Vscode automatically adds a semicolon and jumps to the next line
Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
Lessons and thoughts of the first SQL injection
程序员上班摸鱼,这么玩才高端!
Basic knowledge of road loss of 3GPP channel model
深入解析Kubebuilder
How to package the parsed Excel data into objects and write this object set into the database?
MySQL数据库(基础篇)
Tree map: tree view - draw covid-19 array diagram
C语言中函数指针与指针函数
随机推荐
JS variable case output user name
当 Knative 遇见 WebAssembly
JS variable plus
Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!
架构实战训练营|课后作业|模块 6
Fiance donated 500million dollars to female PI, so that she didn't need to apply for projects, recruited 150 scientists, and did scientific research at ease!
Analyse approfondie de kubebuilder
JS variable
STM32封装ESP8266一键配置函数:实现实现AP模式和STA模式切换、服务器与客户端创建
Canteen user dish relationship system (C language course design)
Oracle -- 视图与序列
Ansible中的inventory主机清单(预祝你我有数不尽的鲜花和浪漫)
JDBC link Oracle reference code
Can I specify a path in an attribute to map a property in my class to a child property in my JSON?
jvm是什么?jvm调优有哪些目的?
Leetcode notes
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
R descriptive statistics and hypothesis testing
STM32F103 realize IAP online upgrade application
【线段树实战】最近的请求次数 + 区域和检索 - 数组可修改+我的日程安排表Ⅰ/Ⅲ