Key differences between InnoDB and MyISAM in the [MySQL] storage engine

Source: Internet
Author: User
Tags table definition

1, transaction processing

InnoDB supports transactional features, MyISAM not supported. Myisam executes faster and performs better.   2,select, UPDATE, INSERT, delete operation  MyISAM: If performing a large number of select,myisam is a better choice InnoDB: If your data performs a large number of inserts or update, for performance reasons, you should use the InnoDB table   3, locking mechanism is different  InnoDB is a row-level lock and MyISAM is a table-level lock. Note: When the database is not determined, the row you are looking for is also locked into the entire table. such as:Update table Set num = ten where username like "%test%"; 4, the number of rows in the query table is differentMyISAM:Select COUNT (*) from Table,myisam simply read the number of rows saved, and note that when the COUNT (*) statement contains a where condition, the operation of the two tables is the same  InnoDB : The exact number of rows in the table is not saved in InnoDB, that is, when the select count (*) from table is executed, InnoDB will scan through the entire table to calculate how many rows   5, different physical structure  MyISAM: Each MyISAM is stored on disk as three files. The first file name begins with the name of the table, and the extension indicates the file type. The. frm file stores the table definition. The data file has an extension of. MYD (MYData).the extension of the index file is. MYI (Myindex)InnoDB: A disk-based resource is a InnoDB tablespace data file and its log file, and the size of the InnoDB table is limited only by the size of the operating system file, typically 2GB different 6,anto_increment mechanismsbetter and faster auto_increment processing     Other: WhyMyISAM will be faster than the InnoDB query. InnoDB when doing select, to maintain more than the MyISAM engine much more;
1) data block, InnoDB to cache, MyISAM only cache the index block, which also has the reduction of swap-out;
2) InnoDB addressing to map to the block, and then to the line, MyISAM record is directly the offset of the file, positioning is faster than InnoDB
3) InnoDB also need to maintain MVCC consistent; Although your scene is not, he still needs to check and maintain MVCC (multi-version Concurrency Control) multi-version concurrency controlsInnoDB: Implement MVCC by adding two additional hidden values for each row of records, one to record when this row of data was created, and another to record when this row of data expires (or is deleted). However, InnoDB does not store the actual time at which these events occur, but instead only stores the system version number when these events occur. This is a growing number of transactions as they are created. Each transaction will record its own system version number at the beginning of the transaction. Each query must check whether the version number of each row of data is the same as the version number of the transaction. Let's take a look at how this policy is applied to specific operations when the isolation level is RepeatableRead: SELECT InnoDB must have each row of data to ensure that it complies with two conditions: 1, InnoDB must find a version of the line, at least as old as the version of the transaction ( That is, its version number is not greater than the version number of the transaction.  This ensures that the data is present either before the transaction starts, or when the transaction is created, or when the row data is modified. 2. The deleted version of this line of data must be undefined or larger than the transaction version. This ensures that this row of data is not deleted before the transaction begins.

Key differences between InnoDB and MyISAM in the [MySQL] storage engine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.