The difference between mysql's innodb storage engine and myisam storage engine

The main differences are as follows:

   1. Transaction support. InnoDB supports transactions, transaction-safe (ACID compliant) tables with transaction (commit), rollback and crash recovery capabilities. For InnoDB, each SQL language is encapsulated into a transaction by default. Automatic commit will affect the speed , so it is best to put multiple SQL languages ​​between begin and commit to form a transaction; while myisam emphasizes performance, each query is atomic, and its execution is more efficient than the InnoDB type. Fast, but does not provide transaction support.

   2. Differences in table locks. myisam only supports table-level locks. When a user operates a myisam table, select, update, delete, and insert statements will automatically lock the table; innodb supports transaction and row-level locks, which is the biggest feature of innodb. Row locks greatly improve the new performance of multi-user concurrent operations. However , the row lock of InnoDB is only valid for the primary key of WHERE, and the WHERE of non-primary key will lock the whole table.

   3, the primary key difference. MyISAM allows tables without any index and primary key to exist, and the index is the address of the row; if InnoDB does not set a primary key or a non-empty unique index , it will automatically generate a 6-byte primary key (not visible to users) , and the data is Part of the main index, the additional index holds the value of the main index.

   4, foreign key differences. MyISAM does not support foreign keys, while innodb supports foreign keys.

   5. Storage structure. Each MyISAM table is stored as three files on disk . The name of the first file begins with the name of the table , and the extension indicates the file type. .frm files store table definitions. Data files have the extension .MYD (MYData). Index files have the extension .MYI (MYIndex ). Innodb is composed of .frm files , tablespaces (divided into independent tablespaces or shared tablespaces, if innodb_file_per_table=true is configured in the configuration file or an independent tablespace will be used without configuration) and log files (redo log) .

 

Guess you like

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