What is the difference between MyISAM and InnoDB?

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:

  1. 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)
  2. insert less, query more
  3. no need for business

InnoDB is suitable for: 

  1. Reliability requirements are high, or transaction support is required
  2. Table updates and queries are frequent
  3. 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

 

 

 

Guess you like

Origin blog.csdn.net/xmbcc777/article/details/130449968