MySQL Logic module composition

Source: Internet
Author: User

In general, MySQL can be seen as a two-tier architecture, the first layer we are often called SQL layer, in the MySQL database system before processing the underlying data is done in this layer, including the permission to judge, SQL resolution, Execution plan optimization, query cache processing and so on The second layer is the storage engine layer, often called the storage engine layers, which is the underlying data storage operation implementation part, composed of a variety of storage engines. So, you can use the Tathagata MySQL infrastructure.

              

Multiple sub-modules are included in the SQL layer

1. Initialize the module

Initialization module is when the MySQL server starts, the whole system to do a variety of initialization operations, such as the various Buffer,cache structure initialization and memory space applications, the initialization of various system variables, various storage engine initialization settings, and so on.

2. Core API

The core API module is designed to provide some very efficient implementation of the underlying operational functions, including implementation of various underlying data structures, implementation of special algorithms, string processing, digital processing, small file I/O, formatted output, and the most important memory management part.

3. Network Interaction Module

The underlying network interaction module abstracts the interface APIs used by the underlying network interaction, enabling the receiving and sending of the underlying data to facilitate the invocation of other modules and the maintenance of the part.

4. Client & Server Interaction Protocol Module

   Any c/s structure of the software system, are sure you have their own unique information exchange protocol, MySQL is no exception. MySQL's Client & Server Interaction Protocol Module Section implements all of the protocols that clients have with MySQL during the interaction process. Of course, these protocols are based on the existing OS and network protocols.

5. User Module

The user module realizes the function, mainly includes the user's login connection permission control and the user's authorization management. He decided to "open the door" to the visitor, just like the door guard at MySQL.

6. Access Control Module

  What do you want to do when you visit the guests? For security reasons, the Access control module is required to monitor the guest's actions in real time and give different privileges to different guests. The function of the access control module is to control the user's access to the data according to the authorization information of each user in the user module and various constraints peculiar to the database itself. Both the user module and the Access control module combine to form the rights security management function of the whole MySQL database system.

7. Connection management, connection threading, and thread management

The connection management module listens to various requests for MySQL server, receives connection requests, forwards all connection requests to the thread management module, and each client request for MySQL server on each connection is assigned (or created) by a connection thread for its individual service. The main task of connection thread is to be responsible for the communication between MySQL server and client, receiving command request from client, passing the result information of server side, etc. The thread management module is responsible for managing the maintenance of these connection threads, including thread creation, thread cache, and so on.

Simply put: The connection module is responsible for monitoring and forwarding the connection request to the thread management module, which is responsible for maintaining the connection thread and the connection thread is responsible for communicating with MySQL server and the client.

8. Query parsing and forwarding module

In MySQL we are accustomed to send all client side to server side command to be query, in MySQL server, the connection thread receives a query from the client, The query will be passed directly to the individual query classification and then forwarded to the corresponding processing module, this module is the query parsing and forwarding module. The main task is to make the query statement semantic and grammatical parsing, and then according to different types of operation classification, and then make targeted forwarding.

9. Query Cache Module

The query cache module is a very important module in MySQL, his main function is to submit the client to the MySQL Select Class query request return result set cache into memory, and a hash value of the query to do a corresponding. When any data changes occur to the base table of the data taken by the query, MySQL automatically invalidates the query's cache. In the application system with high reading and writing, Query cache is very significant for the performance improvement. Of course, its memory consumption is also very large.

10. Query Optimizer module

Query optimizer, which is to optimize the client request query, according to the client request query statement, and the database of some statistics, on the basis of a series of algorithms to analyze, to obtain an optimal strategy, tell the following program how to get the results of this query statement.

11. Table Change Management module

Table Change Management module is mainly responsible for the completion of some DML and DLL query, such as: update,delete,insert,create table,alter table and other statements processing.

12. Table Maintenance Module

Table status checks, bug fixes, and optimizations and analyses are all things that the table maintenance module needs to do.

13. System State Management Module

The System State Management module is responsible for returning various state data to the user when the client requests the state of the system, as the DBA often uses the show Status command, the show variables command, and so on, and the result is that the module returns.

14. Table Manager

This module is very easy to confuse with the table change and the table maintenance module in the name, but its function is completely different from the change and maintenance module, you know, each MySQL table has a table definition file, that is, *.frm file. The main task of the Table manager is to maintain these files, as well as the structure information of each table when a cache, the main content in the cache. Also maintains table-level lock management.

15. Log Recording Module

The logging module is responsible for logging the entire system-level logic layer, including ERR log,binary log,show query log, and so on.

16. Copy Module

Replication module can be divided into Master module and slave module two parts, Master module is mainly responsible for reading the binary log of the master side in the relication environment, as well as the slave side of the I/O thread interaction and other work. The slave module is slightly more than what the Master module is asking for, and is mainly embodied on two threads in the system. One is responsible for requesting and receiving binary logs from Master and writing the I/O thread in the local relay log. The other one is responsible for reading the related log events from realy log and parsing them into a command that can be executed correctly on the slave side and get exactly the same results as the master, and then handed to the SQL thread executed by slave.

17. Storage Engine Interface Module

The storage Engine interface module can be said to be one of the most distinctive features of the MySQL database. Currently, only MySQL can implement plug-in management of the underlying data storage engine in a variety of database products. This module is actually an abstract class, but it is precisely because it can successfully abstract the various data, it is to achieve today's MySQL pluggable storage engine features.

This article references: "MySQL performance tuning and architecture design"

MySQL Logic module composition

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.