InnoDB vs. MyISAM: MySQL Performance Compared

Updated

MySQL database server illustration

Use InnoDB unless you have a specific, tested reason not to — it’s the default engine in MySQL 8.4, it’s the only one of the two with transactions, row-level locking, foreign keys, and crash recovery, and since MySQL 5.6 it also does full-text search, which used to be MyISAM’s one exclusive feature. The sections below are commands run against a real 8.4.10 instance, not descriptions.

Why there is no throughput table

A fair InnoDB-vs-MyISAM throughput benchmark needs a fixed dataset, a fixed concurrency level, and a fixed durability setting (innodb_flush_log_at_trx_commit) that all change the result, so picking one configuration and presenting it as “the” speed of an engine would be misleading. What follows instead is what’s categorically true about each engine, checked against this server.

What SHOW ENGINES actually says on 8.4.10

mysql> SHOW ENGINES;
Engine              Support  Transactions  Comment
InnoDB              DEFAULT  YES           Supports transactions, row-level locking, and foreign keys
MyISAM              YES      NO            MyISAM storage engine
MEMORY               YES      NO            Hash based, stored in memory, useful for temporary tables

mysql> SHOW VARIABLES LIKE 'default_storage_engine';
default_storage_engine   InnoDB

One engine you will not find in that list, whatever an older comparison table told you: Aria. It is MariaDB’s crash-safe successor to MyISAM and has never shipped in MySQL. The command above is how you check rather than trusting any table — information_schema.engines is the same data if you prefer a query.

MyISAM is still supported, still installable, and not deprecated — but it has not been the default since MySQL 5.5 (2010), and nothing in a fresh 8.4 install picks it automatically. If a table on your server is MyISAM, someone specified ENGINE=MyISAM.

MEMORY’s comment in that listing — “useful for temporary tables” — is the other line worth reading carefully. It describes what the engine is for, not what you get: a CREATE TEMPORARY TABLE with no ENGINE= clause gets InnoDB on 8.4, the same as a permanent table, and you have to ask for MEMORY by name.

Full-text search works on InnoDB

Describing full-text indexing as a MyISAM capability without mentioning InnoDB was accurate before MySQL 5.6 (2013) and has been wrong for over a decade since. On this server, right now:

CREATE TABLE hw_w18_ft_innodb (id INT PRIMARY KEY, body TEXT, FULLTEXT(body)) ENGINE=InnoDB;
INSERT INTO hw_w18_ft_innodb VALUES
  (1,'the quick brown fox jumps over the lazy dog'),
  (2,'MySQL storage engines InnoDB and MyISAM compared');
SELECT id FROM hw_w18_ft_innodb WHERE MATCH(body) AGAINST('MyISAM');
+----+
| id |
+----+
|  2 |
+----+

FULLTEXT on ENGINE=InnoDB works exactly like that, unedited. It is not a reason to pick MyISAM anymore.

Transactions: a real rollback, not a description of one

CREATE TABLE hw_w18_txn_innodb (id INT PRIMARY KEY, val VARCHAR(20)) ENGINE=InnoDB;
CREATE TABLE hw_w18_txn_myisam (id INT PRIMARY KEY, val VARCHAR(20)) ENGINE=MyISAM;
START TRANSACTION;
INSERT INTO hw_w18_txn_innodb VALUES (1,'inserted');
INSERT INTO hw_w18_txn_myisam VALUES (1,'inserted');
ROLLBACK;
SELECT COUNT(*) FROM hw_w18_txn_innodb;  -- 0
SELECT COUNT(*) FROM hw_w18_txn_myisam;  -- 1

Same ROLLBACK, same session. The InnoDB row vanished; the MyISAM row is permanent, because MyISAM has no transaction log to undo from — every statement commits itself, immediately, regardless of what you wrap around it.

Foreign keys: MyISAM doesn’t reject the syntax, it silently drops it

CREATE TABLE hw_w18_parent_myisam (id INT PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE hw_w18_child_myisam (
  id INT PRIMARY KEY, parent_id INT,
  FOREIGN KEY (parent_id) REFERENCES hw_w18_parent_myisam(id)
) ENGINE=MyISAM;
SHOW CREATE TABLE hw_w18_child_myisam;
-- CREATE TABLE `hw_w18_child_myisam` (
--   `id` int NOT NULL, `parent_id` int DEFAULT NULL,
--   PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`)
-- ) ENGINE=MyISAM
INSERT INTO hw_w18_parent_myisam VALUES (1);
INSERT INTO hw_w18_child_myisam VALUES (1, 99);  -- parent 99 doesn't exist
SELECT * FROM hw_w18_child_myisam;  -- (1, 99) -- it's in there

No error, no constraint in the resulting table definition — just a plain index. The same statement on ENGINE=InnoDB fails immediately with error 1452, “foreign key constraint fails,” which was also run and produced exactly that error on the first attempt. 1452 is the child-side refusal; deleting a parent row that something still references gives 1451 instead, and the message names the constraint but not the rows blocking you.

Locking, timed: row-level vs whole-table

Session A holds a lock for 3 seconds; session B tries to write. Wall-clock, unedited:

InnoDB, different row (id=2) while A locks id=1:  0.018s  (no wait)
InnoDB, same row (id=1) while A locks it:         2.454s  (blocked until A commits)
MyISAM, different row (id=2) while A holds
  LOCK TABLES ... WRITE on the whole table:        2.581s  (blocked — MyISAM has no concept of "different row")

InnoDB’s row-level locking let session B through instantly for an unrelated row. MyISAM’s table-level write lock blocked session B regardless of which row it wanted, because MyISAM locks the entire table for the duration of a write. Row locks are also what makes a deadlock possible at all — two transactions each holding a row the other needs next, which InnoDB detects and resolves by killing one of them. A table lock cannot deadlock that way; it just queues.

In a database called hw_w18_verify_innodb_myisam, which it creates on whatever server mysql -u root reaches, a script replays the engine listing, the full-text match, the rollback, the orphaned foreign-key row and the InnoDB row-lock timing above; the database is left in place, with the DROP DATABASE command printed rather than run.

Crash recovery: not independently reproduced here

InnoDB uses write-ahead logging (the redo log) and replays it automatically on startup after an unclean shutdown — this is documented behavior, not something safely demonstrable with a kill -9 against a shared instance without risking the other test tables on it. MyISAM has no redo log; after an unclean shutdown a table can come up marked crashed and need REPAIR TABLE or myisamchk. Citing MySQL 8.4’s InnoDB recovery documentation rather than claiming a corruption test that wasn’t run.

For sizing the InnoDB buffer pool once you’ve picked InnoDB, see the buffer pool and memory tuning guide, which measures the same server’s actual innodb_buffer_pool_size behavior.

Photo of author
Sudhir P. founded HeatWare.com in 1999 and has built and operated it full-stack ever since; it is now used by more than 88,000 people. He writes here about the PostgreSQL, MySQL, Linux and DevOps work that keeps it running. Articles are rewritten only after the commands in them have actually been run, and the verification scripts are published alongside them so anyone can check the claims. Reach him at blog@heatware.net.