Logical modules of MySQL Architecture

Source: Internet
Author: User
The logic module of MySQL architecture can be regarded as the first layer of SQLLayer in the layer-2 architecture, including permission judgment, SQL parsing, execution plan optimization, and querycache processing; the StorageEngineLayer layer is an implementation part of the underlying data access operations. It consists of multiple storage engines. SQLLayer package

The logic module of MySQL architecture can be regarded as the first Layer of SQL Layer in the Layer 2 architecture, including permission judgment, SQL parsing, execution plan optimization, and query cache processing; the Storage Engine Layer (L2) is the implementation of underlying data access operations and is composed of multiple Storage engines. SQL Layer

Logical modules of the MySQL Architecture
MySQL can be viewed as a layer-2 architecture.
The first Layer of SQL Layer includes permission judgment, SQL parsing, execution plan optimization, and query cache processing;
The Storage Engine Layer (L2) is the implementation of underlying data access operations and is composed of multiple Storage engines.

The SQL Layer contains multiple submodules:
1. initialization module
When MySQL Server is started, various initialization operations are performed on the entire system, such as various buffer, cache structure initialization, memory space application, and initialization settings of various system variables, various storage engine initialization settings, and so on.
2. Core APIs (the source code is in the mysys and strings folders)
Provides optimization implementation that requires very efficient underlying operation functions, including implementation of various underlying data structures, implementation of special algorithms, string processing, digital processing, and small file I/O, format the output and the most important memory management part.
3. Network Interaction module (the source code is under the vio folder)
The underlying Network Interaction module abstracts the interface APIs used by the underlying network interaction to receive and send the underlying network data, so that other modules can call and maintain the data.
4. Client and Server interaction protocol module
Any software system with a C/S structure will certainly have its own unique information interaction protocol, and MySQL is no exception. The Client and Server interaction protocol module of MySQL implements all protocols during the interaction between the Client and MySQL. Of course, these protocols are built on existing OS and network protocols, such as TCP/IP and Unix Socket.
5. User Module
The functions implemented by the user module mainly include user login connection permission control and user authorization management.
6. Access Control Module
The access control module controls user access to data based on the authorization information of users in the user module and various constraints specific to the database itself. The User Module and the access control module are combined to form the permission security management function of the entire MySQL database system.
7. Connection Management, connection line and thread management
The connection management module monitors various requests to the MySQL Server, receives connection requests, and forwards all connection requests to the thread management module. Each client request connecting to the MySQL Server is allocated (or created) a connection thread to serve it separately. The main task of the connection thread is to communicate with the MySQL Server and the client, accept the client's command requests, and transmit the Server's result information. The thread management module is responsible for managing and maintaining these connection threads. Including thread creation and thread cache.
8. Query parsing and forwarding Module
The main task is to analyze the semantics and syntax of the query statement, and then divide the statement according to different operation types.
Note: The commands sent from all clients to the Server are called query
9. Query Cache Module
Cache the returned result set of the Select query request submitted by the client to MySQL into the memory, which corresponds to a hash value of the query. After any data changes to the base table of the retrieved data in the Query, MySQL automatically invalidates the Cache of the query. In application systems with a very high read/write ratio, Query Cache significantly improves performance. Of course, it also consumes a lot of memory.
10. Query Optimizer Module
Optimize the query of client requests. Analyze the query statements of client requests and some statistical information in the database based on a series of algorithms to obtain an optimal strategy, tell the subsequent program how to obtain the results of this query statement.
11. Table Change Management Module
The table change management module is mainly responsible for processing DML and DDL queries, such as update, delte, insert, create table, and alter table statements.
12. Table maintenance module
Table status check, error repair, and optimization and analysis are all required by the table maintenance module.
13. system status management module
The system status management module is responsible for returning various status data to users when the client requests the system status, such as the show status commands and show variables commands commonly used by DBAs, the result is returned by this module.
14. Table Manager
The work of the table manager is to maintain the *. frm file and a cache. The main content of the cache is the structure information of each table. It also maintains table-Level Lock management.
15. Logging Module
The logging module is mainly responsible for logging the entire system-level logic layer, including error log, binary log, and slow query log.
16. Copy Module
The replication module can be divided into the Master module and the Slave module:
The Master module is mainly responsible for reading binary logs on the Master side in the Replication environment and interacting with the I/O threads on the Slave side.
The Slave module does a little more work than the Master module. It is mainly reflected in two threads in the system:
One is responsible for requests from the Master and receiving binary logs, and writing them to the I/O thread in the local relay log.
One is reading related log events from relay logs, it is then parsed into the SQL thread that can be correctly executed on the Slave side and get the same result as the Master side, and then handed over to the Slave for execution.
17. Storage engine interface module
Implement plug-in management of its underlying data storage engine. It has successfully abstracted various data processing to form a unique feature of the MySQL pluggable storage engine.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.