Summary of MySQL Myisam and Innodb _ MySQL

Source: Internet
Author: User
Summary of MySQL Myisam and Innodb comparison bitsCN.com

Summary of MySQL Myisam and Innodb

Summarize the differences between MySQL Myisam and Innodb engines.

First, the two are in the file structure:

Myisam will store three files:. frm storage table structure,. MYD storage table data,. MYI file storage table index; therefore, the complete copy of a table is required for all three files. In addition, Myisam compresses indexes. Myisam backup is easier.

There are also Innodb. frm table structure files, but data storage is different. because of the concept of table space, data files may be independent or idle. if they are independent, data and indexes will all be in one. ibd file.

Transaction support:

Myisam is not supported. Therefore, if you really need features such as transactions and foreign keys, discard them.

Innodb supports ACID features such as transactions and rollback, and supports foreign keys.

Lock:

Myisam only supports table locks, meaning that if you execute a DML statement (data manipulation language, I .e. add, delete, modify, and query), the entire table will get a lock, before the operation is completed, others cannot operate on this table. Therefore, if the table concurrency is high, Myisam performance may be worse.

Myisam supports row locks, that is, you can lock only a row rather than the entire table. Therefore, in the case of concurrent operations, the performance of Update operations will be better. Of course, if an SQL statement cannot determine the scan range, it also locks the table, such as the where like '%' operation. To put it simply, if Innodb uses the where to retrieve columns without indexes, the table will be locked.

DML (Insert, Select, Update, Delete ):

Select: it is generally considered that Myisam has better read performance than Innodb. Therefore, if it is a project with fewer reads and writes, Myisam can be used as a plus.

Insert: in this case, Myisam is obviously faster for single-threaded operations, but not necessarily for concurrent operations. It should be noted that Myisam supports the Insert Delayed operation. if your application can accept this method (it may take effect after a delay), it will be better.

Update: Innodb is generally considered to be faster.

Delete: Innodb, which deletes a table from a row instead of creating a new table.

Others:

Count (*): Myisam stores the specific number of rows in the table, but innodb does not. Therefore, when you use phpmyadmin to view the number of rows in the table '~ 'Approximate number of rows. So select count (*) is faster to use Myisam, but this is the case without the where condition.

Myisam also supports full-text indexing. for example, if you search for text fields such as where * like "% *", the performance and efficiency will be better.

Auto_Increment: Innodb must contain only the index of this field, while Myisam can use the union index.

Tables created by Myisam can use the Myisam_merge engine, which is useful in some cases.

BitsCN.com

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.