MySQL Engines MyISAM and Innodb

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 21:38, 21 January 2014 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

First off, it should be noted that MyISAM and Innodb are not the only two engines that MySQL supports. These are the two most common engines. A MySQL database can have its tables utilize a mix of different table engine types or all of the same type. MyISAM is the default table engine type for MySQL 5.0. Distributions such as Redhat, Fedora, and CentOS tend to default to Innodb.

spencer7593 of Stack Overflow, The Difference Between MyISAM and Innodb wrote,

The main differences between InnoDB and MyISAM ("with respect to designing a table or database" you asked about) are support for "referential integrity" and "transactions".

If you need the database to enforce foreign key constraints, or you need the database to support transactions (i.e. changes made by two or more DML operations handled as single unit of work, with all of the changes either applied, or all the changes reverted) then you would choose the InnoDB engine, since these features are absent from the MyISAM engine.

Those are the two biggest differences. Another big difference is concurrency. With MyISAM, a DML statement will obtain an exclusive lock on the table, and while that lock is held, no other session can perform a SELECT or a DML operation on the table. Those two specific engines you asked about (InnoDB and MyISAM) have different design goals. MySQL also has other storage engines, with their own design goals.

So, in choosing between InnoDB and MyISAM, the first step is in determining if you need the features provided by InnoDB. If not, then MyISAM is up for consideration.

It table access is mostly read only.

Advantages to MyISAM

Reads can be faster on MyISAM vs Innodb despite what the general claims on the above two links when MyISAM table has fixed (not dynamic) row size i.e. when it uses more CHARs for example versus VARCHARs. Innodb must perform additional checks owing to its ACID (Atomicity, Consistency, Isolation, Durability) compliant nature, so for example a FK check needs to be checked which could potentially cause an operational overhead.

A MyISAM table that is using FULL TEXT Indexing can not be converted to an Innodb Table Engine type.

Advantages to InnoDB

If you need ACID compliance and need your db to be transactional then choosing Innodb is an obvious choice. If table access is a relatively even mix of reads (not requiring full text indexing) and writes then InnoDB is recommended. MyISAM tables should be converted to Innodb when frequent table lock escalations for long periods of time occur. If a read is slow or hasn't completed and a read/write is waiting on the first read to finish then the MyISAM table referenced in the read is held in a locked state till the result set is made available to the query. This also causes a rise in the load average on the server and slows the site down. During this time no reads or writes can complete of course as MyISAM only has table-level locking.