The InnoDB storage engine innoDB is the default transaction engine of mysql. it is also the most important and widely used storage engine. It is designed to handle a large number of short-term transactions. short-term transactions are normally committed and rarely rolled back. The innodb performance and automatic crash recovery feature enable InnoDB storage engine
InnoDB is the default transaction engine of mysql and the most important and widely used storage engine. It is designed to handle a large number of short-term transactions. short-term transactions are normally committed and rarely rolled back. Innodb's performance and automatic crash recovery feature make it popular in non-transactional storage needs. Unless other storage engines are needed for special reasons, the innodb storage engine should be given priority.
Innodb data is stored in tablespaces, which are a black box managed by innodb and composed of a series of data files. In versions later than mysql4.1, innodb can store the data and indexes of each table in a separate file. Innodb can also use bare devices as the storage medium for tablespaces, but modern file systems make bare devices no longer necessary.
Innodb adopts mvcc to support high concurrency and achieves four standard isolation levels. The default value is repeatable read, and the gap lock policy is used to prevent Phantom read. The gap lock makes innodb not only lock the rows involved in the query, but also lock the gap in the index to prevent phantom row insertion.
Innodb tables are created based on clustering indexes, which have high performance in primary key query. However, its secondary index must contain the primary key column. Therefore, if the primary key column is large, other indexes will be large.
MyISAM storage engine
In mysql 5.1 and earlier versions, myisam is the default storage engine. Myisam provides many features, including full-text indexing, compression, spatial functions (GIS), etc, however, myisam does not support transactions and row-level locks, and there is no doubt that it cannot be safely restored after a crash. Because of the myisam engine, even though mysql has been supporting transactions for a long time, mysql is still a non-transactional database in many concepts. Although the myisam engine does not support transactions and secure responses after a crash, it is not useless. Myisam can still be used for read-only data or small tables that can tolerate repair operations.
Myisam stores the table in two files: data files and index files, with. myd and. myi as extension names respectively. Myisam tables can contain dynamic or static rows with fixed length. Mysql determines the row format based on the table definition. The number of row records that can be stored in the myisam table, which is generally limited by the available disk controls or the maximum size of a single file in the operating system.
Myisam locks the entire table instead of the row. A shared lock will be applied to all tables to be read, and an exclusive lock will be applied to tables during write. However, when a table reads a query, it can also insert a new record into the table, which is called concurrent insert.
For myisam tables, mysql can perform manual or automatic check and repair operations. However, the repair and transaction reply and crash recovery mentioned here are different concepts. Performing table repair may cause some data loss and the repair operation is very slow. You can check the table mytable for errors. if any, you can execute repair table mytable to fix the errors. In addition, if the mysql server has been disabled, you can use the myisamchk command line tool to check and fix the problem.
For myisam tables, even long fields such as blob and text can also be indexed based on the first 500 characters. myisam also supports full-text indexing, which is an index created based on word segmentation, supports complex queries.
If the delay_key_write option is specified during myisam table creation, the modified index data is not written to the disk immediately after each modification is completed, but to the key buffer in the memory, the corresponding index block is written to the disk only when the key buffer is cleared or the table is closed. This method can greatly improve the write performance, but the index will be damaged when the data or host crashes, and the repair operation needs to be performed. Delayed index update operations can be set globally or for a single table