MyISAM
|
InnoDB
|
Differences in composition:
|
Each MyISAM is stored as three files on the disk. The name of the first file starts with the name of the table. The extension indicates the file type.
. Frm file storage table definition.
The data file extension is. MYD (MYData ).
The extension of the index file is. MYI (MYIndex ).
|
Disk-based resources are InnoDB tablespace data files and their log files. The InnoDB table size is limited by the operating system file size, generally 2 GB |
Transaction processing:
|
MyISAM tables emphasize performance, and the execution speed is faster than that of InnoDB tables, but transactions are not supported.
|
InnoDB provides advanced database functions such as transactions and external keys.
|
Select update, INSERT, and Delete operations |
If you execute a large number of SELECT statements, MyISAM is a better choice.
|
1. If you execute a large number of INSERT or UPDATE operations on your data, you should use the InnoDB table for performance considerations.
2. When deleting FROM table, InnoDB does not create a new table, but deletes a row.
3. the load table from master operation does not work for InnoDB. The solution is to first change the InnoDB TABLE to the MyISAM TABLE, and then change the imported data to the InnoDB TABLE, however, it is not applicable to tables that use additional InnoDB features (such as foreign keys ).
|
Operation on AUTO_INCREMENT
|
Internal processing of an AUTO_INCREMEN column in each table.
MyISAM automatically updates this column for INSERT and UPDATE operations. This makes the AUTO_INCREMENT column faster (at least 10% ). After the value at the top of the sequence is deleted, it cannot be reused. (When the AUTO_INCREMENT column is defined as the last column of the Multi-column index, the deleted value from the top of the sequence can be reused ).
The AUTO_INCREMENT value can be reset using alter table or myisamch.
For fields of the AUTO_INCREMENT type, InnoDB must contain only the index of this field. However, in the MyISAM table, you can create a joint index with other fields.
Better and faster auto_increment Processing
|
If you specify an AUTO_INCREMENT column for a table, the InnoDB table handle in the data dictionary contains a counter named Automatic growth counter, which is used to assign new values to the column.
The automatic growth counter is only stored in the primary memory, rather than on the disk.
For more information about the Algorithm Implementation of this calculator, see
How does the AUTO_INCREMENT column work in InnoDB?
|
The number of rows in the table. |
Select count (*) from table, MyISAM simply reads the number of rows saved. Note that when the count (*) statement contains the where condition, the operations of the two tables are the same.
|
InnoDB does not store the specific number of rows in the table. That is to say, when you execute select count (*) from table, InnoDB needs to scan the entire table to calculate the number of rows.
|
Lock |
Table lock
|
Provides locking on row level and non-locking read in SELECTs). In addition, the row lock of the InnoDB table is not absolute. If MySQL cannot determine the scope to be scanned when executing an SQL statement, the InnoDB table will also lock the entire table, for example, update table set num = 1 where name like "% aaa %"
|