As long as the system can obtain a database connection from the database connection pool , Can execute CRUD. You can connect the to be executed through the database SQL issue MySQL.

gross crud boy Only know :

* implement insert After statement , There will be multiple pieces of data in the table
* implement update after , Changes table data
* implement delete after , The data in the table will be deleted
* implement select after , Will query the data in the table
* If SQL Performance disgrace , Build several indexes to solve
* …
This should be the cognition of many engineers in the industry to the database , Completely when he is a black box to build tables and execute SQL.

<> Network connections must be threaded

Suppose there is a connection in the connection pool of the database server , Received a message SQL Network request , Please think :

* Who is responsible for listening for network requests from this connection ?
* Who is responsible for reading the request data from the network connection ?
The network must have a thread to listen for requests and read request data , For example, a message sent by a business system is read and parsed from the network connection SQL sentence :

<>SQL Interface

Responsible for handling the received SQL sentence .

MySQL The worker thread reads one from a network connection SQL After statement , How will this be performed SQL And ?

MySQL Provided SQL Interface (SQL Interface), A set of execution SQL Statement interface , Those sent by the special execution business system CRUD sentence

therefore MySQL Worker thread received SQL After statement , Will be handed over to SQL Interface to execute :

<> query parser

that SQL How does the interface execute SQL Declarative ? This thing can understand this SQL sentence ?

The assumptions are as follows SQL:
select id,name,age from users where id=1
This requires a query parser (Parser), Responsible for analysis SQL sentence , Like that SQL Disassembly assembly :

* From “users” Query data in table
* query “id” The value of the field is equal to 1 That line of data
* For the line of data found out, the data in it should be extracted “id,name,age” Three fields
SQL Parsing is by SQL Syntax to parse SQL What is the intention of the statement :

<> query optimizer

Know through the parser SQL What are you doing , Then you have to find the query optimizer (Optimizer) Select an optimal query path .

What is the optimal query path ?

The previous one SQL: from “users” Query data in table , check “id” The value of the field is equal to 1 That line of data , For the line of data found out, the data in it should be extracted “id,name,age” Three fields .

To complete this, there are the following query paths :

* Direct to users In table id Field equals 1 That line of data , Find out that line of data id,name,age Three field values
First users Of each row of data in the table “id,name,age” Check the values of all three fields , Then filter it out from this batch of data “id” Field equals 1 That line of data “id,name,age” Three fields
so , Complete the SQL, Both paths can be realized , Which one do you choose ? Obviously, the first one has better performance .

So the query optimizer probably means that , He'll target you SQL Generate query tree , Select the optimal query path .

Call storage engine interface , Real implementation SQL sentence .

The optimal query path selected by the query optimizer , That is, what kind of order and steps should be followed to implement this SQL Statement plan , Leave the plan to the underlying storage engine for real implementation .

Suppose that some of our data exists in memory , Some have disk files , How the hell do you know

* What data is in memory ?
* Which are on disk ?
When executing :

* Is to update memory data ?
* Or update disk data ?
If disk data is updated :

* Which disk file to query first
* Which disk file to update again ?
This requires a storage engine , It's an executive SQL Declarative , The memory cache data will be queried step by step , Number of disks updated according to , Query disk data, etc , Perform a series of operations of this kind :

MySQL In architecture design ,SQL Interface ,SQL Parser , Query optimizers are generic , Belongs to a set of components . However, it supports various storage engines , as InnoDB,MyISAM,Memory etc. , You can choose which storage engine to use to be responsible for execution SQL.

<> Actuator

Call the interface of the storage engine according to the execution plan .

The storage engine can help us access data in memory and on disk , Who will adjust the interface of the storage engine ?

That's the actuator , According to the implementation scheme selected by the optimizer , Call the interface of the storage engine in a certain order and step , implement SQL logic .

For example, the actuator may first call an interface of the storage engine , obtain “users” The first row of data in the table , Then judge the accuracy of this data “id” Is the value of the field equal to a value we expect , If not , Then continue to call the interface of the storage engine , To get “users” Data in the next row of the table .

That's all , The executor will execute according to the execution plan generated by the optimizer , Keep calling the interfaces of the storage engine , To finish SQL Statement execution plan , That is, constantly updating or extracting some data :

©2019-2020 Toolsou All rights reserved,
【C++ Must see for entry 】C++ from 0 reach 1 Introductory programming axios Interceptor packaging and use Spring Boot Interview must ask : Automatic configuration principle VMware 16 install centos 7 Detailed tutorial C Language data structure - Sequence table delete duplicates V2.0.0 The 12th Blue Bridge Cup c++b Group personal problem solving On sending data from serial port single chip microcomputer to upper computer centos7 install RabbitMqjava Polymorphic array of opencv-python Fourier transform and inverse transform