Preface: MySQL default engine changes
In MySQL 5.5, the InnoDB storage engine replaced the original engine MyISAM as the new default storage engine
So we have to think about why MySQL developers choose to use InnoDB? Because they are aware of the shortcomings of the MyISAM engine in many aspects, as well as some limitations for future development, such as:
Disadvantages of MyISAM
- Does not support transactions, does not support foreign keys
- Does not support row-level locks, the minimum granularity is table-level locks, prone to lock conflicts
- Cannot recover safely after a crash
With the development of technology, companies of all sizes will encounter some concurrency security issues. If thread conflicts occur and data read/write errors occur, it will cause certain consequences, and it will not be good for the user experience. Therefore, under this market demand, MySQL gradually realized the importance of concurrency security, and replaced the InnoDB storage engine with better concurrency handling. The InnoDB storage engine made up for the concurrency shortcomings of MyISAM, such as supporting transactions, foreign keys, and row-level locks, security recovery, etc.
Applicable scenarios are different
However, it does not mean that the InnoDB storage engine is omnipotent. It is not as good as MyISAM in some aspects. The following are the scenarios where the two engines are suitable:
MyISAM is suitable for:
- Calculation of too many counts (the count will be calculated and stored by default, and it is not necessary to calculate every time, which improves the efficiency)
- insert less, query more
- no need for business
InnoDB is suitable for:
- Reliability requirements are high, or transaction support is required
- Table updates and queries are frequent
- Scenarios prone to table locking
Different support functions
Attributes | MyISAM | InnoDB |
affairs | not support | support |
lock granularity | table lock | row level lock |
storage | split file | table space |
isolation level | none | all |
data primary key | no | yes |
MVCC | not support | support |
Cache data records | none | have |
Safe recovery after database crash | not support | support |
performance | weak | powerful |