MySQL storage engine Introduction

Source: Internet
Author: User
The storage engine is a MySQL component used to process SQL operations on different types of tables. It is also known as the table type. MySQL supports multiple storage engines. For Example, the latest MySQL5.6 supports nine storage engines, including InnoDB, MyISAM, Memory, CSV, Archive, Blackhole, Merge, Federated, and Example; different storage engines

The Storage Engine is a MySQL component that processes SQL operations on different types of tables. It is also known as the table type. MySQL supports a variety of storage engines. For Example, the latest MySQL 5.6 supports nine storage engines, including InnoDB, MyISAM, Memory, CSV, Archive, Blackhole, Merge, Federated, and Example; different storage engines

The Storage Engine is a MySQL component that processes SQL operations on different types of tables. It is also known as the table type.
MySQL supports a variety of storage engines. For Example, the latest MySQL 5.6 supports nine storage engines, including InnoDB, MyISAM, Memory, CSV, Archive, Blackhole, Merge, Federated, and Example; different storage engines have different functions, performance, and applicable scenarios.
MySQL versions earlier than 5.5.5 use MyISAM as the default storage engine. MySQL versions earlier than 5.5.5 use InnoDB as the default storage engine.

View the storage engines supported by MySQL:
Use the "show engines;" SQL statement to query the storage engines currently supported by MySQL. The following is the information in MySQL 5.1.61 in RHEL:

mysql> show engines;+------------+---------+------------------------------------------------------------+--------------+------+------------+| Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |+------------+---------+------------------------------------------------------------+--------------+------+------------+| MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         || CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         || MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         || InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        || MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |+------------+---------+------------------------------------------------------------+--------------+------+------------+5 rows in set (0.00 sec)

The engine with the Support field being DEFAULT is the DEFAULT storage engine.

View the storage engine used by each table in the database:
Mysql> show table status from my-db-name;

Specify storage engine (configuration ):
1. in the mysql configuration file (/etc/my. conf), for example, use "default-storage-engine = innodb" to specify InnoDB as the default storage engine.
2. add parameters such as "-default-storage-engine = innodb" or "-default-table-type = myisam" (PS: for the mysqld service in the RHEL system, you can modify/etc/init. d/$ exec in the mysqld file ).
3. Specify the storage ENGINE type when creating a TABLE, for example, create table mytable (id int, title char (20) ENGINE = innodb
4. Change the storage ENGINE used by a TABLE. The SQL statement is ALTER TABLE mytable ENGINE = MyISAM.

Differences between different storage engines:
InnoDB supports transactions with ACID (A: atomicity. c: consistency. i: isolation. d: durability. atomicity, consistency, isolation, and durability. InnoDB also supports foreign keys and row-level locking ).
MyISAM does not support transactions, foreign keys (but its access speed is fast), and table-level locks (rather than fine-grained row-level locks ).
The Memory storage engine is also called HEAP in older MySQL databases. It stores all data in the Memory and has the advantage of fast reading and writing, generally, data that is not important but needs to be quickly searched (such as temporary tables) is stored ).
The following table is from the official MySQL website and compares the features of some mainstream storage engines:

Table 14.1. Storage Engines Feature Summary

Feature MyISAM Memory InnoDB Archive NDB
Storage limits 256 TB RAM 64 TB None 384EB
Transactions No No Yes No Yes
Locking granularity Table Table Row Table Row
MVCC No No Yes No No
Geospatial data type support Yes No Yes Yes Yes
Geospatial indexing support Yes No No No No
B-tree indexes Yes Yes Yes No No
T-tree indexes No No No No Yes
Hash indexes No Yes No [a] No Yes
Full-text search indexes Yes No Yes [B] No No
Clustered indexes No No Yes No No
Data caches No N/ Yes No Yes
Index caches Yes N/ Yes No Yes
Compressed data Yes [c] No Yes [d] Yes No
Encrypted data [e] Yes Yes Yes Yes Yes
Cluster database support No No No No Yes
Replication support [f] Yes Yes Yes Yes Yes
Foreign key support No No Yes No No
Backup/point-in-time recovery [g] Yes Yes Yes Yes Yes
Query cache support Yes Yes Yes Yes Yes
Update statistics for data dictionary Yes Yes Yes Yes Yes

[A] InnoDB utilizes hash indexes internally for its Adaptive Hash Index feature.

[B] InnoDB support for FULLTEXT indexes is available in MySQL 5.6.4 and higher.

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

[D] Compressed InnoDB tables require the InnoDB Barracuda file format.

[E] Implemented in the server (via encryption functions), rather than in the storage engine.

[F] Implemented in the server, rather than in the storage engine.

[G] Implemented in the server, rather than in the storage engine.

References:
Storage engines: http://dev.mysql.com/doc/refman/5.6/en/storage-engines.html
MyISAM: http://dev.mysql.com/doc/refman/5.6/en/myisam-storage-engine.html
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/innodb-storage-engine.html

Original article address: MySQL storage engine introduction, thanks to the original author for sharing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.