MySQL 存储引擎(storage engine)
show engines ;
https://dev.mysql.com/doc/refman/5.7/en/storage-engines.html
创建表时(CREATE TABLE Statement)可以指定存储引擎类型
简介
-
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
, see Chapter 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 a “stub” that does nothing. You can create tables with this engine, but no data can be stored in them or retrieved from them.
对比
Feature | MyISAM | Memory | InnoDB | Archive | NDB |
---|---|---|---|---|---|
B-tree indexes | Yes | Yes | Yes | No | No |
Backup/point-in-time recovery (note 1) | Yes | Yes | Yes | Yes | Yes |
Cluster database support | No | No | No | No | Yes |
Clustered indexes | No | No | Yes | No | No |
Compressed data | Yes (note 2) | No | Yes | Yes | No |
Data caches | No | N/A | Yes | No | Yes |
Encrypted data | Yes (note 3) | Yes (note 3) | Yes (note 4) | Yes (note 3) | Yes (note 3) |
Foreign key support | No | No | Yes | No | Yes (note 5) |
Full-text search indexes | Yes | No | Yes (note 6) | No | No |
Geospatial data type support | Yes | No | Yes | Yes | Yes |
Geospatial indexing support | Yes | No | Yes (note 7) | No | No |
Hash indexes | No | Yes | No (note 8) | No | Yes |
Index caches | Yes | N/A | Yes | No | Yes |
Locking granularity | Table | Table | Row | Row | Row |
MVCC | No | No | Yes | No | No |
Replication support (note 1) | Yes | Limited (note 9) | Yes | Yes | Yes |
Storage limits | 256TB | RAM | 64TB | None | 384EB |
T-tree indexes | No | No | No | No | Yes |
Transactions | No | No | Yes | No | Yes |
Update statistics for data dictionary | Yes | Yes | Yes | Yes | Yes |
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. Support for foreign keys is available in MySQL Cluster NDB 7.3 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.
备注
默认InnoDB, 属于高效和高可用能力均衡的引擎。开发者是 Innobase OY ,已被Oracle收购。( Innovation base 创新基地??)
常用的两种InnoDB和 MyISAM
2005年10月10日,甲骨文公司宣布收购Innobase OY,该公司是一家芬兰的开放源码软件开发商。
由Innobase开发的离散交易数据库InnoDB是依照开放源码许可的标准进行分销的。 甲骨文公司负责数据库与中间件技术的执行副总裁Charles Rozwat说:
“甲骨文公司长期以来一直是Linux、Apache等开放源码软件的支持者。
Innobase是一家富有创新精神、 规模较小的开放源码数据库开发商。
收购Innobase以后,甲骨文将继续发展InnoDB技术并加强对开放源码软件的承诺。
甲骨文已经为Linux提供了一个开放源码集群文件系统。
我们将来会在开放源码软件领域做出更多贡献。” InnoDB不是独立的数据库产品,而是作为MySQL数据库的一部分进行分销。
InnoDB与MySQL原有的合约将于明年到期,甲骨文公司希望双方能够通过洽谈续约。
InnoDB
https://dev.mysql.com/doc/refman/5.7/en/innodb-introduction.html
Innobase OY 开发的数据库。Innovation base ??
MyISAM
https://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html
Indexed Sequential Access Method