Mysql architecture and Mysql engine

Mysql architecture


1. Connection layer: Responsible for receiving connection requests from clients

The top layer is some client and connection services, including local sock communication and most tcp/ip-like communication implemented based on client/server tools. It mainly completes some connection processing, authorization authentication, and related security solutions.

2. Service layer: sql interface receives sql, parser sql syntax analysis, query optimizer SQL optimization, cache

The second-layer architecture mainly completes most of the core service functions, such as SQL interfaces, and completes cached queries, SQL analysis and optimization, and the execution of some built-in functions. All cross-storage engine functions are also implemented in this layer, such as procedures, functions, etc. At this layer, the server will parse the query and create the corresponding internal parse tree, and complete the corresponding optimization, such as determining the order of the query table, whether to use prime references, etc., and finally generate the corresponding execution operation. If it is a select statement, the server will also query the internal cache. If the cache space is large enough, it can greatly improve system performance in an environment that handles a large number of read operations.

3. Engine layer: It is the specific way to implement it . Different storage engines have different characteristics and store data in files.

Storage engine layer, the storage engine is really responsible for the storage and retrieval of data in MysQL, and the server communicates with the storage engine through API. Different storage engines have different functions, so we can choose according to our actual needs.

4. Physical file storage layer: Use various files to store data and various log files.

The data storage layer mainly stores data on the file system running on the raw device and completes the interaction with the storage engine.

Mysql engine


What is a data engine?

A storage engine is a specific way of manipulating data; data in MySQL is stored in files using a variety of different technologies. Each of these technologies uses different storage mechanisms, indexing techniques, locking levels, and ultimately provides a wide range of different functions and capabilities. These different technologies and supporting related functions are called storage engines in MYSQL.

It is used to set up the table. It can be specified when creating the table or modified afterwards. It mainly uses the data engine to create, query, update and delete data into files .

Different storage engines provide different storage mechanisms, indexing techniques, locking levels and other functions. Using different storage engines, you can also obtain specific functions. When facing different database situations, it also supports the use of multiple data engines.

What are the benefits of choosing the right data engine?

Through the use of an engine, you can gain additional speed and functionality, improving the overall functionality of your application. Storage engines can be selected for servers, databases, and tables to provide maximum flexibility in choosing how to store your information, how to retrieve it, and what performance and functionality you need for your data.

How to define a data engine

View supported engines

SHOW ENGINES;

view table engine

SHOW TABLE STATUS LIKE 'table name'

Modify the engine

Method 1: Set default-storage-engine=InnoDB in mysql.ini and restart the service.

Method 2: Specify CREATE TABLE table name (...) ENGINE=MYISAM when creating the table;

Method 3: Modify the ALTER TABLE table name ENGINE = INNODB after creating the table;

Note: We usually execute the storage engine when creating the table.

Storage engines mainly include:

Storage engines mainly include:

1.MyIsam, 2. InnoDB 3. Memory, 4. Blackhole, 5. CSV, 6. Performance_Schema, 7. Archive, 8. Federated, 9 Mrg_Myisam We mainly analyze the use of MyIsam and InnoDB.

Functions supported by some databases:

Innodb engine : supports transactions and row-level locks (when a transaction operates on a certain row of data, it will only lock a certain row of data and not other rows. It is highly efficient and supports high-concurrency operations). It supports foreign key constraints and cache. It supports full-text index and does not store the total number of rows in the table. The default is innodb when creating the table; suitable for scenarios with many additions, deletions and modifications.

MyISAM:不支持事务,不支持主外键,不支持行级锁,支持表锁(进行增删改dml操作时,会锁定整张表),主要用于查询操作多,增删改操作较少的场景,支持全文索引,存储表的总行数。

Guess you like

Origin blog.csdn.net/weixin_52394141/article/details/129257957