An introduction to the four engines commonly used in MySQL

Introduction of four commonly used engines in MySQL
(1): MyISAM storage engine: does not support transactions or foreign keys, the advantage is that the access speed is fast, there is no requirement for transaction integrity, or applications based on select and insert can basically Use this engine to create a table
Support 3 different storage formats, namely: static table; dynamic table; compressed table

Static table: the fields in the table are all non-variable-length fields, so that each record is of fixed length, and the advantages of storage are Very fast, easy to cache, and easy to recover from failures; the disadvantage is that it usually takes up more space than dynamic tables (because spaces are filled according to the width of the column during storage) ps: When fetching data, the spaces behind the fields will be removed by default , if you don't pay attention, the spaces in the data itself will also be ignored.

Dynamic table: The record is not of fixed length, so the advantage of this storage is that it takes up relatively less space; Disadvantage: Frequent updates and deletion of data are prone to fragmentation, and the OPTIMIZE TABLE or myisamchk-r command needs to be executed regularly to improve performance
Compression table: because Each record is compressed individually, so there is very little access overhead

(2) InnoDB storage engine*
This storage engine provides transaction safety with commit, rollback, and crash recovery. However, compared to the MyISAM engine, the write processing efficiency will be less, and it will take up more disk space to retain data and indexes. 
The characteristics of the InnoDB storage engine: support for automatic growth of columns, support for foreign key constraints

(3): MEMORY storage engine
Memory storage engine uses the content that exists in memory to create tables. Each memory table actually corresponds to only one disk file, and the format is .frm. The memory type table access is very fast, because its data is placed in memory, and the HASH index is used by default, but once the service is shut down, the data in the table will be lost. 


The table of the MEMORY storage engine can choose to use the BTREE  index or the HASH index. The two different types of indexes have different scopes
. Unlike the B-Tree index, which requires multiple IO accesses from the root node to the branch node, and finally to the page node, the query efficiency of the Hash index is much higher than that of the B-Tree index. 
Disadvantages of Hash index: It is also obvious for inaccurate search, because the hash algorithm is based on equivalent calculation, so it is invalid and unsupported for the range search of "like" and other ranges.
What content changes are the memory type storage engines mainly used for? Infrequent code tables, or intermediate result tables for statistical operations, facilitate efficient analysis of intermediate results and obtain final statistical results. Be careful when updating a table whose storage engine is memory, because the data is not actually written to the disk, so you must consider how to obtain the modified data after restarting the service next time.

(4) MERGE storage engine
The Merge storage engine is a combination of a set of MyISAM tables. These MyISAM tables must have the same structure. The merge table itself has no data. The merge type table can be queried, updated, and deleted. These operations actually This is done on an internal MyISAM table.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325520636&siteId=291194637