How to select a suitable MySQL storage engine this article will introduce the features of multiple MySQL storage engines, hoping to help you when selecting a MySQL storage engine.
MySQL has multiple storage engines:
MyISAM, InnoDB, MERGE, MEMORY (HEAP), BDB (BerkeleyDB), EXAMPLE, FEDERATED, ARCHIVE, CSV, and BLACKHOLE.
MySQL supports several storage engines as processors for different table types. The MySQL storage engine includes the engine for processing transaction security tables and the engine for processing non-transaction security tables:
◆ MyISAM manages non-transaction tables. It provides high-speed storage and retrieval, as well as full-text search capabilities. MyISAM is supported in all MySQL configurations. it is the default storage engine, unless you configure MySQL to use another engine by default.
◆ The MEMORY storage engine provides "in-MEMORY" tables. The MERGE storage engine allows a set to process the same MyISAM table as a separate table. Like MyISAM, MEMORY and MERGE storage engines process non-transaction tables. Both engines are included in MySQL by default.
Note: the MEMORY storage engine is officially identified as the HEAP engine.
◆ InnoDB and BDB storage engines provide transaction security tables. BDB is included in the MySQL-Max binary distribution version released for the operating system that supports it. InnoDB is also included in all MySQL 5.1 binary distributions by default. you can configure MySQL to allow or disable any engine as you like.
◆ The EXAMPLE storage engine is a "stub" engine, which does not do anything. You can use this engine to create tables, but no data is stored or retrieved from them. The purpose of this engine is to provide a service. in the MySQL source code example, it demonstrates how to start writing a new storage engine. Similarly, it is mainly interested in developers.
◆ NDB Cluster is a storage engine used by MySQL Cluster to split tables into multiple computers. It is provided in MySQL-Max 5.1 Binary distribution. Currently, this storage engine is only supported by Linux, Solaris, and Mac OS X. In the future MySQL distribution version, we want to add support for this engine from other platforms, including Windows.
◆ The ARCHIVE storage engine is used to cover a large amount of data stored without indexing.
◆ The CSV storage engine stores data in text files in comma-separated formats.
◆ The BLACKHOLE storage engine accepts but does not store data, and retrieval always returns an empty set.
◆ FEDERATED Storage Engine stores data in a remote database. In MySQL 5.1, it only works with MySQL and uses the MySQL C Client API. In future distributions, we want to connect it to another data source using another drive or client connection method.
When creating a new TABLE, you can add an ENGINE or TYPE option to the create table statement to tell MySQL what TYPE of TABLE you want to CREATE:
Create table t (I INT) ENGINE = INNODB;
Create table t (I INT) TYPE = MEMORY;
Although TYPE is still supported in MySQL 5.1, ENGINE is the preferred term.
How to select the storage engine that best suits you?
The following storage engines are the most commonly used:
◆ MyISAM: the default MySQL plug-in storage engine, which is one of the most commonly used storage engines in Web, data warehousing, and other application environments. Note: by changing the STORAGE_ENGINE configuration variables, you can easily change the default storage engine of the MySQL server.
◆ InnoDB: used for transaction processing applications. it has many features, including ACID transaction support.
◆ BDB: it can replace InnoDB's transaction engine and supports COMMIT, ROLLBACK, and other transaction features.
◆ Memory: stores all data in RAM and provides extremely fast access in environments where reference and other similar data need to be quickly searched.
◆ Merge: allows MySQL DBAs or developers to logically combine a series of equivalent MyISAM tables and reference them as one object. It is suitable for VLDB environments such as data warehousing.
◆ Archive: provides a perfect solution for storing and retrieving a large number of rarely referenced historical, archived, or security audit information.
◆ Federated: connects multiple separated MySQL servers and creates a logical database from multiple physical servers. It is very suitable for Distributed Environments or data mart environments.
◆ Cluster/NDB: MySQL's Cluster-based database engine is especially suitable for applications with high-performance search requirements. such search requirements also require the highest normal working time and availability.
◆ Other: Other storage engines include CSV (referencing files separated by commas as database tables) and Blackhole (used to temporarily prohibit database application input ), and the Example engine (which can help you quickly create a custom plug-in storage engine ).
Remember that you do not have to use the same storage engine for the entire server or solution. you can use different storage engines for each table in the solution. this is very important.
Mysql> show engines;
+ ------------ + --------- + ---------------------------------------------------------------- +
| Engine | Support | Comment |
+ ------------ + --------- + ---------------------------------------------------------------- +
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys |
| BerkeleyDB | NO | Supports transactions and page-level locking |
| BLACKHOLE | NO |/dev/null storage engine (anything you write to it disappears) |
| EXAMPLE | NO | Example storage engine |
| ARCHIVE | NO | Archive storage engine |
| CSV | NO | CSV storage engine |
| Ndbcluster | NO | Clustered, fault-tolerant, memory-based tables |
| FEDERATED | NO | Federated MySQL storage engine |
| MRG_MYISAM | YES | Collection of identical MyISAM tables |
| ISAM | NO | Obsolete storage engine