当前位置:网站首页>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 .
边栏推荐
- Flask项目使用flask-socketio异常:TypeError: function() argument 1 must be code, not str
- [Yugong series] go teaching course 005 variables in July 2022
- 指针与数组在函数中输入实现逆序输出
- Tree map: tree view - draw covid-19 array diagram
- STM32封装ESP8266一键配置函数:实现实现AP模式和STA模式切换、服务器与客户端创建
- A detailed explanation of head pose estimation [collect good articles]
- Introduction to the PureMVC series
- 一文搞懂常见的网络I/O模型
- 【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
- Markdown editor
猜你喜欢
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
How to package the parsed Excel data into objects and write this object set into the database?
U++ 元数据说明符 学习笔记
【实践出真理】import和require的引入方式真的和网上说的一样吗
Local tool [Navicat] connects to remote [MySQL] operation
R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
MySQL数据库(基础篇)
计数排序基础思路
Flex layout and usage
随机推荐
Meaning of 'n:m' and '1:n' in database design
System framework of PureMVC
Some understandings about 01 backpacker
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
A picture to understand! Why did the school teach you coding but still not
5G VoNR+之IMS Data Channel概念
[Yugong series] go teaching course 005 variables in July 2022
Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
动态生成表格
Can I specify a path in an attribute to map a property in my class to a child property in my JSON?
What work items do programmers hate most in their daily work?
Read of shell internal value command
Inventory host list in ansible (I wish you countless flowers and romance)
Station B boss used my world to create convolutional neural network, Lecun forwarding! Burst the liver for 6 months, playing more than one million
R descriptive statistics and hypothesis testing
U++ 游戏类 学习笔记
If you ask me about R code debugging, I will tell you head, STR, help
npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
日常工作中程序员最讨厌哪些工作事项?
The most complete learning rate adjustment strategy in history LR_ scheduler