Summary: In this tutorial, you will learn how MySQL storage engines work, what makes InnoDB different from MyISAM, MEMORY, ARCHIVE and other engines, and how to choose the right storage engine for your tables.
One interesting feature of MySQL is that the database server does not necessarily store every table in exactly the same way.
MySQL uses a pluggable storage engine architecture. A storage engine is the component responsible for storing and retrieving the actual table data. Depending on the engine, it can also determine how indexes, transactions, locking, foreign keys and crash recovery work.
This means two tables inside the same MySQL database can use completely different storage engines.
For example:
CREATE TABLE users (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL
) ENGINE=InnoDB;
And another table could use:
CREATE TABLE temporary_lookup (
id INT NOT NULL,
value VARCHAR(255)
) ENGINE=MEMORY;
Modern MySQL provides several storage engines, including:
- InnoDB
- MyISAM
- MEMORY
- CSV
- ARCHIVE
- MERGE
- FEDERATED
- BLACKHOLE
MySQL NDB Cluster also provides the NDB storage engine for clustered environments.
However, these engines should not be considered equal alternatives.
For almost every normal application today, InnoDB should be your default choice. The other engines solve specialized problems or exist primarily for compatibility with older MySQL applications.
Let's look at how they differ.
Checking Available MySQL Storage Engines
Before choosing an engine, you can check which engines are available on your MySQL server:
SHOW ENGINES;
The result looks roughly like this:
Engine Support Transactions
----------------------------------------
InnoDB DEFAULT YES
MyISAM YES NO
MEMORY YES NO
CSV YES NO
ARCHIVE YES NO
...
DEFAULT indicates the engine MySQL uses when you create a table without explicitly specifying one.
You can also query the INFORMATION_SCHEMA:
SELECT
ENGINE,
SUPPORT,
TRANSACTIONS,
XA,
SAVEPOINTS
FROM INFORMATION_SCHEMA.ENGINES;
In MySQL 8.4, InnoDB is the default storage engine.
Therefore:
CREATE TABLE users (
id BIGINT PRIMARY KEY
);
normally creates an InnoDB table even though ENGINE=InnoDB was not explicitly specified.
InnoDB
InnoDB is the general-purpose storage engine used by modern MySQL applications.
If you are building a web application, API, SaaS platform, e-commerce system or practically any other transactional application, InnoDB is usually what you want.
InnoDB supports:
- ACID-compliant transactions;
COMMITandROLLBACK;- foreign keys;
- row-level locking;
- multi-version concurrency control (MVCC);
- crash recovery;
- B-tree indexes;
- full-text indexes;
- spatial indexes.
A transaction, for example, allows several database operations to succeed or fail as one unit:
START TRANSACTION;
UPDATE accounts
SET balance = balance - 100
WHERE id = 1;
UPDATE accounts
SET balance = balance + 100
WHERE id = 2;
COMMIT;
If something goes wrong before the transaction completes, the changes can be rolled back:
ROLLBACK;
This is extremely important for applications dealing with orders, invoices, payments, inventory or any data where partial updates could leave the database in an inconsistent state.
Another important InnoDB feature is row-level locking.
When one transaction updates a row, MySQL generally does not need to lock the entire table. Other transactions can continue working with other rows.
That makes InnoDB much better suited to applications with many concurrent users.
InnoDB also supports foreign-key constraints:
CREATE TABLE orders (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
customer_id BIGINT UNSIGNED NOT NULL,
CONSTRAINT fk_orders_customer
FOREIGN KEY (customer_id)
REFERENCES customers(id)
) ENGINE=InnoDB;
For most applications there is little reason to choose another engine unless you have a very specific requirement.
Use InnoDB when: you are building almost any normal production application.
MyISAM
MyISAM is one of MySQL's older storage engines and is based on the even older ISAM engine.
Years ago, MyISAM was extremely common. Before MySQL 5.5, it was the default storage engine.
Today, it is primarily encountered in legacy databases and specialized read-heavy workloads.
MyISAM supports:
- B-tree indexes;
- full-text indexes;
- spatial indexes;
- compressed read-only tables;
- very large tables.
However, it has two major limitations:
MyISAM does not support transactions.
This will not work as a real transactional operation:
START TRANSACTION;
UPDATE myisam_table SET value = 1;
ROLLBACK;
MyISAM changes cannot simply be rolled back like changes to an InnoDB table.
It also uses table-level locking instead of InnoDB's row-level locking.
If one query updates a MyISAM table, other queries may need to wait for the table lock. Under a high-concurrency workload, this can quickly become a bottleneck.
MyISAM tables can be checked and repaired using utilities such as mysqlcheck and myisamchk, and read-only MyISAM tables can be compressed using myisampack.
Historically, MyISAM was sometimes chosen because it could outperform InnoDB in certain simple read-heavy workloads. But modern InnoDB is extremely capable, and choosing MyISAM purely because "it is faster" is generally outdated advice.
Use MyISAM when: maintaining a legacy application that requires it or when you have benchmarked a very specialized workload and have a specific reason for using it.
For new application development, prefer InnoDB.
MEMORY
As its name suggests, the MEMORY storage engine stores table data in memory rather than persistently on disk.
It was previously known as the HEAP engine, and HEAP remains a synonym for MEMORY.
For example:
CREATE TABLE online_users (
user_id BIGINT UNSIGNED NOT NULL,
last_activity INT UNSIGNED NOT NULL,
PRIMARY KEY (user_id)
) ENGINE=MEMORY;
Because the data is stored in RAM, MEMORY tables can provide very fast access.
But there is an important catch:
the data disappears when the MySQL server stops or restarts.
The table definition remains, but its rows do not.
MEMORY tables support both hash and B-tree indexes.
Hash indexes are useful for exact lookups:
WHERE user_id = 123
while B-tree indexes are more appropriate for range queries:
WHERE created_at > 1000
or:
WHERE score BETWEEN 100 AND 500
MEMORY tables should therefore only contain data that can safely be lost or reconstructed.
And in modern application architecture, technologies such as Redis often fill many of the roles that developers historically used MEMORY tables for.
Use MEMORY when: you need temporary, non-critical, server-local data and have a specific reason to keep it inside MySQL.
CSV
The CSV storage engine stores table data as plain comma-separated-value files.
For example:
CREATE TABLE export_data (
id INT NOT NULL,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) NOT NULL
) ENGINE=CSV;
MySQL stores the underlying rows in a .CSV file.
That makes the format convenient when another application needs direct access to CSV-formatted data.
However, CSV tables have significant limitations.
They do not support indexes, so queries generally require full table scans. They also do not support transactions or foreign keys.
CSV columns must be declared NOT NULL.
The CSV engine is therefore not intended to replace normal application tables.
Modern applications will usually get better results by keeping their data in InnoDB and exporting CSV when required:
SELECT ...
followed by application-level CSV generation.
Use CSV when: you specifically need a MySQL-managed table backed by a CSV file.
ARCHIVE
The ARCHIVE storage engine is designed for storing large amounts of historical data using a small amount of disk space.
Data stored in ARCHIVE tables is compressed.
For example:
CREATE TABLE request_archive (
created_at DATETIME NOT NULL,
ip_address VARCHAR(45) NOT NULL,
request TEXT NOT NULL
) ENGINE=ARCHIVE;
ARCHIVE supports operations such as:
INSERT
REPLACE
SELECT
but it does not support normal UPDATE or DELETE operations.
It also does not provide indexes.
That means finding individual records can require scanning the table.
Those limitations make sense when you consider its original purpose: storing large quantities of data that are written once and rarely queried.
Potential examples include historical logs or long-term archival records.
However, today you should also consider whether an object store, dedicated logging platform, analytical database or compressed InnoDB table is a better solution.
Use ARCHIVE when: you specifically need compressed, mostly write-once archival data inside MySQL and understand the lack of indexes and updates.
MERGE
The MERGE storage engine, also known as MRG_MyISAM, allows several identical MyISAM tables to be presented as one logical table.
Imagine three tables:
logs_2024
logs_2025
logs_2026
If all three have compatible MyISAM structures, you can create a MERGE table:
CREATE TABLE all_logs (
id BIGINT NOT NULL,
message TEXT NOT NULL,
INDEX(id)
)
ENGINE=MERGE
UNION=(logs_2024, logs_2025, logs_2026);
You can then query:
SELECT *
FROM all_logs;
and MySQL accesses the underlying tables.
The MERGE table itself does not contain the actual data.
This technique was historically useful for splitting very large MyISAM datasets into separate tables.
Today, however, MySQL's native partitioning features usually provide a more natural solution for similar problems.
MERGE also inherits the limitations of MyISAM, including the lack of transactions and foreign keys.
Use MERGE when: working with an existing architecture based on multiple compatible MyISAM tables.
It is rarely a good choice for a new application.
FEDERATED
The FEDERATED storage engine is unusual because the actual table data does not live on the local MySQL server.
Instead, a local FEDERATED table points to a table on another MySQL server.
Conceptually:
Application
|
Local MySQL
|
FEDERATED table
|
Network
|
Remote MySQL table
Queries against the local table retrieve data from the remote server.
A FEDERATED table might look similar to:
CREATE TABLE remote_customers (
id INT NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
)
ENGINE=FEDERATED
CONNECTION='mysql://user:password@remote-server/database/customers';
The local table stores its definition but not the actual rows.
This can be useful when you need to expose a remote MySQL table locally without setting up replication or a cluster.
There are significant tradeoffs, however.
Queries depend on network connectivity and remote-server performance. Distributed joins can become expensive, and you need to consider security carefully because the local server must know how to connect to the remote database.
FEDERATED is also not enabled by default on a normal MySQL server and must be explicitly enabled.
For many modern systems, an API, ETL pipeline, replication or another integration architecture will be preferable.
Use FEDERATED when: you specifically need SQL-level access to tables hosted by another MySQL server and understand the operational tradeoffs.
BLACKHOLE
BLACKHOLE may be the strangest MySQL storage engine.
It accepts data but does not store it.
Think of it as MySQL's /dev/null.
You can create a table:
CREATE TABLE discarded_events (
id BIGINT NOT NULL,
payload JSON NOT NULL
) ENGINE=BLACKHOLE;
Then insert data:
INSERT INTO discarded_events
VALUES (1, '{"event":"test"}');
The operation succeeds.
But:
SELECT *
FROM discarded_events;
returns no rows.
The data is gone.
Why would anybody want this?
BLACKHOLE can be useful in specialized replication architectures because operations can still participate in MySQL's binary logging even though the local server does not retain the table data.
This is definitely not an engine you would use for normal application data, but it demonstrates how flexible MySQL's storage-engine architecture actually is.
Use BLACKHOLE when: you know exactly why you need it, usually for specialized replication or database infrastructure.
NDB
NDB, or NDBCLUSTER, is the storage engine used by MySQL NDB Cluster.
It is designed for distributed, highly available database clusters rather than a traditional single MySQL server.
An NDB Cluster distributes data across multiple data nodes and is designed for environments where high availability and fault tolerance are critical.
NDB is a substantially different architecture from simply changing:
ENGINE=InnoDB
to:
ENGINE=NDB
inside a normal MySQL installation.
If you are running an ordinary web application on a normal MySQL server, you probably do not need NDB.
Use NDB when: your architecture specifically uses MySQL NDB Cluster.
Comparing MySQL Storage Engines
Here is a simplified comparison of the engines most developers are likely to encounter:
| Engine | Transactions | Foreign Keys | Locking | Persistent | Typical Use |
|---|---|---|---|---|---|
| InnoDB | Yes | Yes | Row | Yes | General applications |
| MyISAM | No | No | Table | Yes | Legacy/read-heavy workloads |
| MEMORY | No | No | Table | No | Temporary in-memory data |
| CSV | No | No | Table | Yes | CSV-backed interchange data |
| ARCHIVE | No | No | Row | Yes | Compressed archival data |
| MERGE | No | No | Table | Yes* | Combining MyISAM tables |
| FEDERATED | No | No | — | Remote | Accessing remote MySQL tables |
| BLACKHOLE | No | No | — | No | Replication/infrastructure |
- The MERGE table itself references data stored in underlying MyISAM tables.
How to Find the Storage Engine of a Table
You can inspect a table using:
SHOW TABLE STATUS LIKE 'users';
Or check all tables in a database:
SELECT
TABLE_NAME,
ENGINE
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'my_database';
The result might look like:
+----------------+--------+
| TABLE_NAME | ENGINE |
+----------------+--------+
| users | InnoDB |
| invoices | InnoDB |
| old_logs | MyISAM |
| temporary_data | MEMORY |
+----------------+--------+
This query can be particularly useful when auditing an old MySQL database.
Changing a Table's Storage Engine
MySQL allows you to convert a table from one compatible engine to another using ALTER TABLE.
For example, to convert an old MyISAM table to InnoDB:
ALTER TABLE customers ENGINE=InnoDB;
For a small table this can be straightforward.
For a large production table, however, changing storage engines can be an expensive operation and may require rebuilding the table. Always consider disk space, locking, application traffic and backup strategy before performing such a migration.
Also check whether your schema relies on engine-specific behavior before converting it.
Which MySQL Storage Engine Should You Use?
For the vast majority of developers, the answer is simple:
Use InnoDB.
InnoDB provides the combination of transactions, foreign keys, row-level locking, crash recovery and concurrency expected from a modern relational database.
You generally should not choose MyISAM simply because an old tutorial claims it is faster.
You should not choose MEMORY simply because RAM sounds faster than disk.
And you should not choose ARCHIVE simply because your table contains old data.
Storage-engine decisions should be based on the actual requirements and workload of the application.
A practical rule is:
Normal application data → InnoDB
Legacy MyISAM application → MyISAM, then consider migration
Temporary disposable data → MEMORY
CSV-backed interchange table → CSV
Specialized compressed archive → ARCHIVE
Legacy MyISAM table grouping → MERGE
Remote MySQL table access → FEDERATED
Replication plumbing → BLACKHOLE
MySQL NDB Cluster → NDB
And when in doubt:
ENGINE=InnoDB;
Or simply don't specify an engine at all and let modern MySQL use its default.
Understanding the alternative storage engines is still useful. They demonstrate that the SQL layer you interact with is only one part of MySQL, while the storage engine underneath determines many important properties of how your data is actually stored, indexed, locked and recovered.