当前位置:网站首页>MySQL series: overview of the overall architecture
MySQL series: overview of the overall architecture
2022-06-23 15:24:00 【yue_ xin_ tech】
Preface
Use mysql For many years , But I haven't studied it deeply , Prepare to learn about mysql Relevant knowledge points of . See how this artifact in the programming world works .
mysql Architecture mode of
mysql It's using C/S framework , That is what we usually call the client - Server model . As we usually use workbench、nacivat Is the client , Of course , And command line tools .
They will be based on the specified ip、prot Connect to the server , Through a certain agreement SQL Implementation . These protocols include the most widely used TCP agreement , Sockets suitable for local communication are also included 、 Shared memory 、 Named pipeline and other protocols .
mysql There is a special thread on the server side to manage each connection , And the network IO The model is select/poll, Is not epoll.
Mainly because select/poll Good portability , Many systems support , and mysql The bottleneck is not the network connection , For fewer connections , And the connection is very active mysql for ,select/poll It's a better choice .
( notes :select、poll、epoll yes IO Multiplexing model , Can monitor multiple at the same time I/O The state of the event , Less occupied resources , High performance .)
mysql Of 2 Stages
When the server receives the client's request to connect , Will enter Connection phase and The command phase .
The connection phase mainly performs the following tasks :
- Determine the current version of the client and server ;
- Determine if... Is required SSL signal communication ;
- The server authenticates the identity of the client ;
When the connection phase above ok after , Will enter the command phase , What we usually see SQL The operation is performed at this stage , Such as
COM_QUERY: Used to send an immediate message to the server SQL Inquire aboutCOM_CREATE_DB: Commands for creating databases

mysql Of 3 Layer architecture
above 2 The second stage is from mysql Divided by the connection life cycle , In fact, from the logical structure ,mysql Can be divided into 3 layer :
adjoining course: Mainly responsible for connection pool 、 Communication protocol 、 Certification and authorization ;SQL layer: This floor is mysql Brain , The optimal solution of data operation is obtained through a series of components .Storage layer: Responsible for the storage of data 、 retrieval .
SQL layer
The connection layer has been outlined earlier , Let's see SQL layer , After receiving the command ,mysql Not foolishly go straight to get the data , It will analyze the current sql Various execution efficiencies of statements , And then get an optimal execution plan .
stay SQL The layer is mainly divided into the following functions :
Query cache: Cache query result set , And the next query hit the cache , Then the following execution will be skipped , Returns the cached result directly .Parser: Parser , according to SQL Statement to build an internally used parse tree , For easy access to SQL Information , Such as SQL Semantic and grammatical information .Optimizer: Optimizer , By analyzing the operation cost of the storage engine and the statistics of the table , Output efficient execution plan . For example, in query analysis , Which of table scan or index scan is more efficient , Then choose which .
In addition to the above functions ,mysql Built in functions for 、 stored procedure 、 Triggers and views are also implemented in this layer .
Storage layer
As mentioned earlier, the optimizer will output the execution plan , The specific implementation is in the storage layer . The storage tier is mysql The design here is Can be inserted Plug in for , That is, as long as the standardized interface is met (API), Then you can implement your own storage engine .
The storage engine is used to store 、 To retrieve data , Different storage engines have different characteristics , image InnoDB Support transactions 、 Foreign keys , and MyISAM I don't support .
Generally, we don't need to care SQL Which storage engines are involved in the statement , As mentioned earlier , It has been abstracted through standardized interfaces . However, the optimizer layer may need to make different choices according to different storage engines .
summary
mysql The overall architecture of is described above , actually ,mysql There are still many important knowledge points to master , image Lock mechanism ,MVCC version control , Query optimization etc. , I got it , That's right mysql Have a general understanding , We will continue to study later , Share it with you !
Interested friends can search the official account 「 Read new technology 」, Pay attention to more push articles .
If you can , Just like it by the way 、 Leave a message 、 Under the share , Thank you for your support !
Read new technology , Read more new knowledge .
边栏推荐
- php 二维数组插入
- Pop() element in JS
- Mysql双主配置的详细步骤
- List query sorting parameter processing
- Unshift() and shift() of JS
- AI intelligent robot saves us time and effort
- The well-known face search engine provokes public anger: just one photo will strip you of your pants in a few seconds
- Why is Xiaomi stuck in the chip quagmire?
- MySQL advanced statement 2
- Logistics trade related
猜你喜欢

Gartner's latest report: development of low code application development platform in China

MySQL create and manage tables

golang 重要知识:sync.Cond 机制

The work and development steps that must be done in the early stage of the development of the source code of the live broadcasting room

raspberry pi安装 wiringpi

2021-04-15

golang 重要知识:mutex

volatile~多线程下变量不可见

General sequence representation learning in kdd'22 "Ali" recommendation system

Effect evaluation of regression model under credit product quota pricing scenario
随机推荐
F5 application strategy status report in 2022: edge deployment and load security become the focus of attention in the Asia Pacific Region
Error creating bean with name xxx Factory method ‘sqlSessionFactory‘ threw exception; nested excepti
RF analyzer demo setup
WebService接口发布和调用
volatile~多线程下变量不可见
Mysql database - log management, backup and recovery
Solution to the problem that MySQL cannot be started in xampp
32. Compose 优美的触摸动画
[pyside2] pyside2 window is on the top of Maya (note)
How is it safe to open an account for futures? Which futures company has a relatively low handling fee for futures and is suitable for retail investors to open an account?
Origin of sectigo (Comodo) Certificate
Une compréhension simple du tri rapide
30. concatenate substrings of all words
mysql主从只同步部分库或表的思路与方法
JS traversal array (using the foreach () method)
The work and development steps that must be done in the early stage of the development of the source code of the live broadcasting room
F5《2022年应用策略现状报告》:边缘部署及负载安全成亚太地区关注焦点
SQL injection vulnerability (principle)
Explain in detail the principle and implementation of redis distributed lock
Why is Xiaomi stuck in the chip quagmire?