Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.3Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  Alternative Storage Engines

Chapter 15 Alternative Storage Engines

Table of Contents

15.1 Setting the Storage Engine
15.2 The MyISAM Storage Engine
15.2.1 MyISAM Startup Options
15.2.2 Space Needed for Keys
15.2.3 MyISAM Table Storage Formats
15.2.4 MyISAM Table Problems
15.3 The MEMORY Storage Engine
15.4 The CSV Storage Engine
15.4.1 Repairing and Checking CSV Tables
15.4.2 CSV Limitations
15.5 The ARCHIVE Storage Engine
15.6 The BLACKHOLE Storage Engine
15.7 The MERGE Storage Engine
15.7.1 MERGE Table Advantages and Disadvantages
15.7.2 MERGE Table Problems
15.8 The FEDERATED Storage Engine
15.8.1 FEDERATED Storage Engine Overview
15.8.2 How to Create FEDERATED Tables
15.8.3 FEDERATED Storage Engine Notes and Tips
15.8.4 FEDERATED Storage Engine Resources
15.9 The EXAMPLE Storage Engine
15.10 Other Storage Engines
15.11 Overview of MySQL Storage Engine Architecture
15.11.1 Pluggable Storage Engine Architecture
15.11.2 The Common Database Server Layer

Storage engines are MySQL components that handle the SQL operations for different table types.InnoDB is the default and most general-purpose storage engine, and Oracle recommends using it for tables except for specialized use cases. (TheCREATE TABLE statement in MySQL 5.7 createsInnoDB tables by default.)

MySQL Server uses a pluggable storage engine architecture that enables storage engines to be loaded into and unloaded from a running MySQL server.

To determine which storage engines your server supports, use theSHOW ENGINES statement. The value in theSupport column indicates whether an engine can be used. A value ofYES,NO, orDEFAULT indicates that an engine is available, not available, or available and currently set as the default storage engine.

mysql> SHOW ENGINES\G*************************** 1. row ***************************      Engine: PERFORMANCE_SCHEMA     Support: YES     Comment: Performance SchemaTransactions: NO          XA: NO  Savepoints: NO*************************** 2. row ***************************      Engine: InnoDB     Support: DEFAULT     Comment: Supports transactions, row-level locking, and foreign keysTransactions: YES          XA: YES  Savepoints: YES*************************** 3. row ***************************      Engine: MRG_MYISAM     Support: YES     Comment: Collection of identical MyISAM tablesTransactions: NO          XA: NO  Savepoints: NO*************************** 4. row ***************************      Engine: BLACKHOLE     Support: YES     Comment: /dev/null storage engine (anything you write to it disappears)Transactions: NO          XA: NO  Savepoints: NO*************************** 5. row ***************************      Engine: MyISAM     Support: YES     Comment: MyISAM storage engineTransactions: NO          XA: NO  Savepoints: NO...

This chapter covers use cases for special-purpose MySQL storage engines. It does not cover the defaultInnoDB storage engine or theNDB storage engine which are covered inChapter 14,The InnoDB Storage Engine, andChapter 21,MySQL NDB Cluster 7.5 and NDB Cluster 7.6. For advanced users, this chapter also contains a description of the pluggable storage engine architecture (seeSection 15.11, “Overview of MySQL Storage Engine Architecture”).

For information about features offered in commercial MySQL Server binaries, seeMySQL Editions, on the MySQL website. The storage engines available might depend on which edition of MySQL you are using.

For answers to commonly asked questions about MySQL storage engines, seeSection A.2, “MySQL 5.7 FAQ: Storage Engines”.

MySQL 5.7 Supported Storage Engines

  • InnoDB: The default storage engine in MySQL 5.7.InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance.InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity,InnoDB also supportsFOREIGN KEY referential-integrity constraints. For more information aboutInnoDB, seeChapter 14,The InnoDB Storage Engine.

  • MyISAM: These tables have a small footprint.Table-level locking limits the performance in read/write workloads, so it is often used in read-only or read-mostly workloads in Web and data warehousing configurations.

  • Memory: Stores all data in RAM, for fast access in environments that require quick lookups of non-critical data. This engine was formerly known as theHEAP engine. Its use cases are decreasing;InnoDB with its buffer pool memory area provides a general-purpose and durable way to keep most or all data in memory, andNDBCLUSTER provides fast key-value lookups for huge distributed data sets.

  • CSV: Its tables are really text files with comma-separated values. CSV tables let you import or dump data in CSV format, to exchange data with scripts and applications that read and write that same format. Because CSV tables are not indexed, you typically keep the data inInnoDB tables during normal operation, and only use CSV tables during the import or export stage.

  • Archive: These compact, unindexed tables are intended for storing and retrieving large amounts of seldom-referenced historical, archived, or security audit information.

  • Blackhole: The Blackhole storage engine accepts but does not store data, similar to the Unix/dev/null device. Queries always return an empty set. These tables can be used in replication configurations where DML statements are sent to replica servers, but the source server does not keep its own copy of the data.

  • NDB (also known asNDBCLUSTER): This clustered database engine is particularly suited for applications that require the highest possible degree of uptime and availability.

  • Merge: Enables a MySQL DBA or developer to logically group a series of identicalMyISAM tables and reference them as one object. Good for VLDB environments such as data warehousing.

  • Federated: Offers the ability to link separate MySQL servers to create one logical database from many physical servers. Very good for distributed or data mart environments.

  • Example: This engine serves as an example in the MySQL source code that illustrates how to begin writing new storage engines. It is primarily of interest to developers. The storage engine is astub that does nothing. You can create tables with this engine, but no data can be stored in them or retrieved from them.

You are not restricted to using the same storage engine for an entire server or schema. You can specify the storage engine for any table. For example, an application might use mostlyInnoDB tables, with oneCSV table for exporting data to a spreadsheet and a fewMEMORY tables for temporary workspaces.

Choosing a Storage Engine

The various storage engines provided with MySQL are designed with different use cases in mind. The following table provides an overview of some storage engines provided with MySQL, with clarifying notes following the table.

Table 15.1 Storage Engines Feature Summary

FeatureMyISAMMemoryInnoDBArchiveNDB
B-tree indexesYesYesYesNoNo
Backup/point-in-time recovery (note 1)YesYesYesYesYes
Cluster database supportNoNoNoNoYes
Clustered indexesNoNoYesNoNo
Compressed dataYes (note 2)NoYesYesNo
Data cachesNoN/AYesNoYes
Encrypted dataYes (note 3)Yes (note 3)Yes (note 4)Yes (note 3)Yes (note 5)
Foreign key supportNoNoYesNoYes
Full-text search indexesYesNoYes (note 6)NoNo
Geospatial data type supportYesNoYesYesYes
Geospatial indexing supportYesNoYes (note 7)NoNo
Hash indexesNoYesNo (note 8)NoYes
Index cachesYesN/AYesNoYes
Locking granularityTableTableRowRowRow
MVCCNoNoYesNoNo
Replication support (note 1)YesLimited (note 9)YesYesYes
Storage limits256TBRAM64TBNone384EB
T-tree indexesNoNoNoNoYes
TransactionsNoNoYesNoYes
Update statistics for data dictionaryYesYesYesYesYes

Notes:

1. Implemented in the server, rather than in the storage engine.

2. Compressed MyISAM tables are supported only when using the compressed row format. Tables using the compressed row format with MyISAM are read only.

3. Implemented in the server via encryption functions.

4. Implemented in the server via encryption functions; In MySQL 5.7 and later, data-at-rest encryption is supported.

5. Implemented in the server via encryption functions; encrypted NDB backups as of NDB 8.0.22; transparent NDB file system encryption supported in NDB 8.0.29 and later.

6. Support for FULLTEXT indexes is available in MySQL 5.6 and later.

7. Support for geospatial indexing is available in MySQL 5.7 and later.

8. InnoDB utilizes hash indexes internally for its Adaptive Hash Index feature.

9. See the discussion later in this section.