The difference between MyISAM and InnoDB

Answer: The main differences are as follows:
   a) Differences in structure
     MyISAM is stored in three files on the disk, among which the .frm file stores the table definition; .MYD (MYData) is the data file; .MYI (MYIndex) is the index file .
     Innodb is composed of .frm files, tablespaces (divided into independent tablespaces or shared tablespaces) and log files (redo log).
    b) The difference between transactions
      myisam does not support transactions; while innodb supports transactions.
    c) The difference between locks
 Myisam uses table locks; while innodb uses row locks (of course innodb also supports table locks).
 Table-level lock: directly lock the entire table. During the lock period, other processes cannot write to the table. If a write lock is set, other processes are not allowed to read. Therefore, the concurrency supported by myisam is low, but myisam does not Deadlock will occur;
 row-level lock: only the specified row is locked, and other processes can still operate on other rows in the table. Therefore, row locks can greatly reduce conflicts in database operations, but sometimes lead to deadlocks.
    d) The difference between whether to support foreign keys
 Myisam does not support foreign keys, innodb supports foreign keys
    e) The difference between select count(*)
 For count(*) without where, using MyISAM is much faster than InnoDB. Because MyISAM has a built-in counter, it reads directly from the counter when count(*), and InnoDB must scan the whole table.
    f) myisam only loads indexes into memory, while innodb storage engine loads both data and indexes into memory, innob does not support full-text indexes
This engine is of course preferred when database transactions need to be used. Due to the smaller granularity of the lock, the write operation will not lock the entire table, so when the concurrency is high, using the Innodb engine will improve the efficiency.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325681468&siteId=291194637