[MySQL] Principle of Operation (1): Overall Architecture

MySQL development history and version branches:

time milestone
1996 MySQL1.0 is released. Its history can be traced back to 1979, when the author Monty used BASIC to design a report tool.
October 1996 3.11.1 Release. There is no 2.x version of MySQL.
2000 ISAM is upgraded to MyISAM engine. MySQL is open source.
Year 2003 MySQL4.0 released, integrated InnoDB storage engine
2005 MySQL 5.0 is released, providing functions such as views and stored procedures.
Year 2008 MySQLAB was acquired by Sun and entered the SunMySQL era.
Year 2009 Oracle acquired Sun and entered the age of Oracle MySQL.
year 2010 MySQL5.5 was released, and InnoDB became the default storage engine.
2016 MySQL released version 8.0.0. Why are there no 6, 7? 5.6 can be regarded as 6.x, and 5.7 can be regarded as 7.x.

Because MySQL is open source (there are also paid versions), many branches have been developed based on the stable version of MySQL. Just like Linux, there are Ubuntu, RedHat, CentOS, Fedora, Debian, and so on. The one you are most familiar with should be MariaDB, because CentOS7 comes with MariaDB. How did it come from? After Oracle acquired MySQL, Monty, one of the founders of MySQL, worried about the future of MySQL database development (development is slow, closed, and may be closed source), so he created a branch MariaDB, using the new Maria storage engine by default, which is the original MyISAM storage The upgraded version of the engine.

Other popular branches:

  • Percona Server is one of the important branches of MySQL. Based on the InnoDB storage engine, it has improved performance and ease of management, and finally formed an enhanced version of the XtraDB engine, which can be used to better play the performance of the server hardware.
  • There are also some MySQL branches or self-developed storage engines in China, such as NetEase's InnoSQL, and Jishu Yunzhou's ArkDB.

We have various ways to operate the database, such as the command line in the Linux system, such as the database tool Navicat, such as the program, such as the JDBC API of the Java language or the ORM framework. But have you ever thought about what actually happened when our tools or programs were connected to the database? How does it work internally?

MySQL architecture

Based on the above analysis process, let's sort out the internal modules of MySQL together.

1. Detailed module explanation

[External link image transfer failed. The source site may have an anti-hotlinking mechanism. It is recommended to save the image and upload it directly (img-X8355hj5-1603815339191) (MySQL executes a SQL process.assets/image-20201027175312083.png)]

  1. Connector: Used to support the interaction of various languages ​​and SQL, such as PHP, Python, Java's JDBC
  2. Management Serveices & Utilities: System management and control tools, including backup and recovery, MySQL replication, clustering, etc.
  3. Connection Pool: connection pool, management of resources that need to be buffered, including user password authority threads, etc.
  4. SQL Interface: used to receive the user's SQL commands and return the query results that the user needs
  5. Parser: used to parse SQL statements
  6. Optimizer: query optimizer
  7. CacheandBuffer: query cache, in addition to the row record cache, there are table cache, key cache, permission cache, etc.
  8. Pluggable Storage Engines: Pluggable storage engines, which provide APIs to the service layer to deal with specific files

2. Architecture layering

In general, we can divide MySQL into three layers, the connection layer that connects with the client, the service layer that actually performs operations, and the storage engine layer that deals with hardware (refer to MyBatis: Interface, Core, and Foundation).

  1. Connection layer

    If our client wants to connect to port 3306 of the MySQL server, it must establish a connection with the server. Then manage all connections and verify the identity and permissions of the client. These functions are completed at the connection layer.

  2. Service layer

    The connection layer will hand over the SQL statement to the service layer, which also contains a series of processes: such as query cache judgment, call the corresponding interface according to SQL, and analyze our SQL statement lexical and grammatical (such as how to identify keywords , How to recognize the alias, whether there is any error in the syntax, etc.)

    Then there is the optimizer. The bottom layer of MySQL will optimize our SQL statements according to certain rules, and finally hand them over to the executor for execution.

  3. Storage engine

    The storage engine is where our data is actually stored, and different storage engines are supported in MySQL. Next is the memory or disk.

Summarize the mind map

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43935927/article/details/113979175