Mysql database engine comparison

MySQL can store data in files (memory) with different technologies, which are called storage engines.

write picture description here
Each storage engine uses different storage mechanisms, indexing techniques, locking levels, and ultimately provides a wide range of different capabilities. Types are MyISAM, InnoDB, MERGE, MEMORY(HEAP), BDB(BerkeleyDB), EXAMPLE, FEDERATED, ARCHIVE, CSV, BLACKHOLE.

The size of the data and what kind of business scenarios affect our choice of engine. Large-sized data sets tend to choose the InnoDB method because it supports transaction processing and failure recovery. For database failure recovery time, InnoDB can use the transaction log for data recovery, which will be faster, maybe a few minutes. And MyISAM can take hours or even days to do these things. Of course, MYISAM is still a good choice for secondary data analysis with backup or offline data extracted from the production library.
For a large number of inserts statements will be faster under MyISAM, but updates will be faster under InnoDB - especially when the amount of concurrency is high.

MyISAM (the advantages and disadvantages in different scenarios are relative)
Advantages: The MyISAM engine is simple in design, supports indexing (including full-text retrieval), table-level locking, data can be compressed, and the storage limit can reach 256TB. . Data is stored in a compact format, emphasizing fast read operations, and large amounts of data read operations have great advantages, suitable for cases where transactions are not processed much.
Disadvantages: MyISAM does not support transactions or foreign keys, and there is no requirement for transaction integrity. The file defect of MyISAM format is that data cannot be recovered after table damage.

InnoDB:
Advantages: Supports transactions and indexes, lock particles are row locks, suitable for more transaction processing, storage limit is 64TB, foreign key support, support for crash repair capabilities and concurrency control. If you need to have high requirements on transaction integrity (such as banks) and require concurrency control (such as ticket sales), then choosing InnoDB has great advantages. If you need a database that requires frequent updates and delete operations, you can also choose InnoDB because it supports transaction commit and rollback.
Disadvantages:
1. InnoDB does not support FULLTEXT type indexes.
2. InnoDB does not save the specific number of rows in the table, that is, when executing select count( ) from table, InnoDB needs to scan the entire table to calculate how many rows there are, but MyISAM simply reads the number of saved rows. Can. Note that when the count( ) statement contains a where condition, the operations for both tables are the same.
3. For fields of type AUTO_INCREMENT, InnoDB must contain an index of only this field, but in MyISAM tables, a joint index can be established with other fields.
4. When DELETE FROM table, InnoDB will not recreate the table, but delete row by row.
5. The LOAD TABLE FROM MASTER operation does not work for InnoDB. The solution is to first change the InnoDB table to a MyISAM table, import the data and then change it to an InnoDB table, but for additional InnoDB features (such as foreign keys) used Table does not apply.
In addition, the row lock of the InnoDB table is not absolute. If MySQL cannot determine the range to be scanned when executing an SQL statement, the InnoDB table will also lock the entire table, such as update table set num=1 where name like “%aaa%”

Advantages of memery
: All data is in memory, and the data processing speed is fast. If you need fast read and write speed, and have low requirements for data security, you can choose MEMOEY. Each table based on the MEMORY storage engine actually corresponds to a disk file. The file name of the file is the same as the table name, and the type is frm type. Only the structure of the table is stored in this file. The data files are stored in the memory, which is conducive to the rapid processing of data and improves the efficiency of the entire table. Suitable for relatively small database tables.
Disadvantages: It has requirements on the size of the table, cannot create a table that is too large, and the security is not high.

Guess you like

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