Someone just told me that InnoDB is much better than MyISAM. So when I create a table, should I always try to use InnoDB Engine instead of MyISAM? Or do both have it's big benefits?
The performance of InnoDB for large volumes of data is better as compared to MyISAM. MyISAM doesn't support transactional properties and is faster to read. As compared to InnoDB, the performance for a high volume of data is less.
InnoDB: InnoDB is a storage engine for DBMS MySQL and MariaDB.It is the default storage engine for MySQL versions 5.5 and higher. It replaced MyISAM as the default engine. Features: It provides standard ACID-compliant transaction features, along with foreign key support.
MyISAM will out-perform InnoDB on large tables that require vastly more read activity versus write activity. MyISAM's readabilities outshine InnoDB because locking the entire table is quicker than figuring out which rows are locked in the table.
A big reason to use InnoDB over MyISAM, is the lack of full table-level locking. This allows your queries to process faster.
MyISAM
is transactionless and heap-organized. The records are identified by the row offset in the table and the indexes store this offset as a row pointer.
InnoDB
supports transactions and is index-organized. The records are identified by the value of the PRIMARY KEY
(or a hidden internal column is there is no PRIMARY KEY
defined) and are stored in a B-Tree
. The secondary indexes store the value of the PRIMARY KEY
as a row pointer.
Queries that involve full table scans or secondary index lookups are usually faster on MyISAM
tables.
Queries that involve PRIMARY KEY
seeks are usually faster on InnoDB
tables.
MyISAM
tables store the number of records in the table in the table's metadata, that's why the queries like this:
SELECT COUNT(*)
FROM myisamtable
are instant.
MyISAM
tables are completely locked on the DML
operations (with several exceptions).
InnoDB
tables lock individual records and index gaps, however these are the records and the gaps that are scanned, not only those matched by the WHERE
condition. This can lead to the records being locked despite the fact they don't match.
InnoDB
tables support referential integrity (FOREIGN KEY
s) . MyISAM
tables don't.
There are several scenarios that can show benefits of both engines.
Simple answer: No, you shouldn't.
A few points about each engine:
InnoDB
MyISAM
See more in the Manual:
To put it simply:
You should use InnoDB:
You should use MyISAM:
IMHO you should always prefer InnoDB
over MyISAM
because of the transactional support which is at the heart of every relational database system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With