当前位置:网站首页>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 .
边栏推荐
- Introduction to the PureMVC series
- 史上最全学习率调整策略lr_scheduler
- Basic idea of counting and sorting
- Factor analysis r practice (with R installation tutorial and code)
- 九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
- Tiktok may launch an independent grass planting community platform: will it become the second little red book
- 谈谈讲清楚这件事的重要性
- 装饰器基础学习02
- Flex layout and usage
- 架构实战训练营|课后作业|模块 6
猜你喜欢
U++ 元数据说明符 学习笔记
【实践出真理】import和require的引入方式真的和网上说的一样吗
JS variable plus
[Yugong series] go teaching course 005 variables in July 2022
Ansible中的inventory主机清单(预祝你我有数不尽的鲜花和浪漫)
How does vscade use the built-in browser?
Read of shell internal value command
DFS和BFS概念及实践+acwing 842 排列数字(dfs) +acwing 844. 走迷宫(bfs)
MySQL数据库(基础篇)
Introduction to namespace Basics
随机推荐
STM32 encapsulates the one key configuration function of esp8266: realize the switching between AP mode and sta mode, and the creation of server and client
Inventory host list in ansible (I wish you countless flowers and romance)
Decorator basic learning 02
namespace基础介绍
【736. Lisp 语法解析】
当 Knative 遇见 WebAssembly
Wechat can play the trumpet. Pinduoduo was found guilty of infringement. The shipment of byte VR equipment ranks second in the world. Today, more big news is here
Flask项目使用flask-socketio异常:TypeError: function() argument 1 must be code, not str
Introduction to the PureMVC series
National meteorological data / rainfall distribution data / solar radiation data /npp net primary productivity data / vegetation coverage data
Vscode automatically adds a semicolon and jumps to the next line
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
IMS data channel concept of 5g vonr+
【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
2.证券投资基金的概述
A picture to understand! Why did the school teach you coding but still not
关于01背包个人的一些理解
为什么很多人对技术债务产生误解
【实践出真理】import和require的引入方式真的和网上说的一样吗