mysql database engine (InnoDB MyISAM)

MySQL's default storage engine 'in the previous version 5.5 is MYISAM, after 5.5 is INNODB.

Two storage engine index structure is described in detail B + tree, B + tree reference may https://www.cnblogs.com/yangecnu/p/Introduce-B-Tree-and-B-Plus-Tree.html

InnoDB and MyISAM difference

1. InnoDB supports transactions, MyISAM does not support InnoDB for each SQL language are packaged into the transaction default, auto-commit, this will affect the speed, it is best to place multiple SQL language between the begin transaction and commit, constitute a single transaction ;  

2. InnoDB supports foreign keys, and MyISAM does not support. For a table that contains InnoDB foreign keys into MYISAM fail;  

3. InnoDB is an aggregate index, index and data files are tied together, there must be a primary key, the primary key index is very efficient. But it requires two auxiliary index query, the first query to the primary key, and then query the data by primary key. Therefore, the primary key should not be too big because the primary key is too big, the other indexes also will be great. Whereas non-aggregated MyISAM index, separate data file, the index pointer stored in the data file. Primary key index and secondary indexes are independent.

4. InnoDB specific number of rows of the table is not saved, performs select count (*) requires a full table scan from table. And MyISAM with a variable number of lines to save the whole table, only when executing the read statement to the variable, fast;  

5. Innodb does not support full-text indexing, and MyISAM supports full-text indexing, query on MyISAM higher efficiency;

6. After a system crash, MyISAM more difficult to recover.

About storage engine selection

1. Do you want to support the transaction, if you want to select innodb, if you do not consider MyISAM

2. If the table in the vast majority are just reading queries can be considered MyISAM, if both read and write frequently, it is recommended to use InnoDB.

Guess you like

Origin www.cnblogs.com/coder-lichao/p/10937914.html