8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 18 个替代存储引擎 / 18.5 ARCHIVE 存储引擎
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

18.5 ARCHIVE 存储引擎18.5 The ARCHIVE Storage Engine

ARCHIVE 存储引擎生成用于特殊用途的表,这些表以非常小的存储空间存储大量未索引的数据。The ARCHIVE storage engine produces special-purpose tables that store large amounts of unindexed data in a very small footprint.

表 18.5 ARCHIVE 存储引擎特性Table 18.5 ARCHIVE Storage Engine Features

功能Feature 支持情况Support
B 树索引B-tree indexes 否No
备份/时间点恢复(在服务器中实现,而非在存储引擎中实现。)Backup/point-in-time recovery (Implemented in the server, rather than in the storage engine.) 是Yes
集群数据库支持Cluster database support 否No
聚簇索引Clustered indexes 否No
压缩数据Compressed data 是Yes
数据缓存Data caches 否No
加密数据Encrypted data 是的(通过服务器的加密函数实现。)Yes (Implemented in the server via encryption functions.)
外键支持Foreign key support 否No
全文搜索索引Full-text search indexes 否No
地理空间数据类型支持Geospatial data type support 是Yes
地理空间索引支持Geospatial indexing support 否No
哈希索引Hash indexes 否No
索引缓存Index caches 否No
锁粒度Locking granularity 行Row
多版本并发控制 (MVCC)MVCC 否No
复制支持(在服务器中实现,而不是在存储引擎中。)Replication support (Implemented in the server, rather than in the storage engine.) 是Yes
存储限制Storage limits 无None
T 树索引T-tree indexes 否No
事务Transactions 否No
更新数据字典统计信息Update statistics for data dictionary 是Yes

ARCHIVE 存储引擎包含在 MySQL 二进制发行版中。如果您从源代码构建 MySQL,要启用此存储引擎,请使用 CMake 并带上 -DWITH_ARCHIVE_STORAGE_ENGINE 选项。The ARCHIVE storage engine is included in MySQL binary distributions. To enable this storage engine if you build MySQL from source, invoke CMake with the -DWITH_ARCHIVE_STORAGE_ENGINE option.

要查看 ARCHIVE 引擎的源代码,请查看 MySQL 源代码分发版中的 storage/archive 目录。To examine the source for the ARCHIVE engine, look in the storage/archive directory of a MySQL source distribution.

您可以使用 SHOW ENGINES 语句检查 ARCHIVE 存储引擎是否可用。You can check whether the ARCHIVE storage engine is available with the SHOW ENGINES statement.

当您创建 ARCHIVE 表时,存储引擎会创建以表名开头的文件。数据文件的扩展名为 .ARZ。在优化操作期间,可能会出现 .ARN 文件。When you create an ARCHIVE table, the storage engine creates files with names that begin with the table name. The data file has an extension of .ARZ. An .ARN file may appear during optimization operations.

ARCHIVE 存储引擎支持 INSERT、REPLACE 和 SELECT,但不支持 DELETE 或 UPDATE。它确实支持 ORDER BY 操作、BLOB 列以及空间数据类型(参见 第 13.4.1 节,“空间数据类型”)。不支持地理空间参考系统。ARCHIVE 存储引擎使用行级锁。The ARCHIVE engine supports INSERT, REPLACE, and SELECT, but not DELETE or UPDATE. It does support ORDER BY operations, BLOB columns, and spatial data types (see Section 13.4.1, “Spatial Data Types”). Geographic spatial reference systems are not supported. The ARCHIVE engine uses row-level locking.

ARCHIVE 存储引擎支持 AUTO_INCREMENT 列属性。AUTO_INCREMENT 列可以具有唯一索引或非唯一索引。尝试在任何其他列上创建索引会导致错误。ARCHIVE 引擎还支持在 CREATE TABLE 语句中使用 AUTO_INCREMENT 表选项,用于分别为新表指定初始序列值或重置现有表的序列值。The ARCHIVE engine supports the AUTO_INCREMENT column attribute. The AUTO_INCREMENT column can have either a unique or nonunique index. Attempting to create an index on any other column results in an error. The ARCHIVE engine also supports the AUTO_INCREMENT table option in CREATE TABLE statements to specify the initial sequence value for a new table or reset the sequence value for an existing table, respectively.

ARCHIVE 不支持向 AUTO_INCREMENT 列插入小于当前最大列值的值。尝试这样做会导致 ER_DUP_KEY 错误。ARCHIVE does not support inserting a value into an AUTO_INCREMENT column less than the current maximum column value. Attempts to do so result in an ER_DUP_KEY error.

如果未请求 BLOB 列,ARCHIVE 引擎会忽略它们,并在读取时跳过。The ARCHIVE engine ignores BLOB columns if they are not requested and scans past them while reading.

ARCHIVE 存储引擎不支持分区。The ARCHIVE storage engine does not support partitioning.

存储: 行在插入时会被压缩。ARCHIVE 引擎使用 zlib 无损数据压缩(参见 http://www.zlib.net/)。你可以使用 OPTIMIZE TABLE 来分析表并将其压缩成更小的格式(关于使用 OPTIMIZE TABLE 的原因,请参见本节稍后内容)。该引擎还支持 CHECK TABLE。有几种插入类型被使用:Storage: Rows are compressed as they are inserted. The ARCHIVE engine uses zlib lossless data compression (see http://www.zlib.net/). You can use OPTIMIZE TABLE to analyze the table and pack it into a smaller format (for a reason to use OPTIMIZE TABLE, see later in this section). The engine also supports CHECK TABLE. There are several types of insertions that are used:

  • INSERT 语句只是将行推入压缩缓冲区,并根据需要刷新该缓冲区。插入到缓冲区是由一个锁保护的。SELECT 会强制刷新发生。An INSERT statement just pushes rows into a compression buffer, and that buffer flushes as necessary. The insertion into the buffer is protected by a lock. A SELECT forces a flush to occur.

  • 批量插入只有在完成后才可见,除非同时发生其他插入,在这种情况下,它可能部分可见。SELECT 永远不会在批量插入期间引发刷新,除非在加载时发生普通插入。A bulk insert is visible only after it completes, unless other inserts occur at the same time, in which case it can be seen partially. A SELECT never causes a flush of a bulk insert unless a normal insert occurs while it is loading.

检索:在检索时,行按需解压;没有行缓存。SELECT 操作会执行完整的表扫描:当执行 SELECT 时,它会确定当前可用的行数并读取该数量的行。SELECT 以一致性读取的方式执行。注意,插入期间大量的 SELECT 语句可能会降低压缩效果,除非仅使用批量插入。为了实现更好的压缩,可以使用 OPTIMIZE TABLE 或 REPAIR TABLE。通过 SHOW TABLE STATUS 报告的 ARCHIVE 表中的行数始终是准确的。参见 第 15.7.3.4 节,“OPTIMIZE TABLE 语句”、第 15.7.3.5 节,“REPAIR TABLE 语句” 以及 第 15.7.7.38 节,“SHOW TABLE STATUS 语句”。Retrieval: On retrieval, rows are uncompressed on demand; there is no row cache. A SELECT operation performs a complete table scan: When a SELECT occurs, it finds out how many rows are currently available and reads that number of rows. SELECT is performed as a consistent read. Note that lots of SELECT statements during insertion can deteriorate the compression, unless only bulk inserts are used. To achieve better compression, you can use OPTIMIZE TABLE or REPAIR TABLE. The number of rows in ARCHIVE tables reported by SHOW TABLE STATUS is always accurate. See Section 15.7.3.4, “OPTIMIZE TABLE Statement”, Section 15.7.3.5, “REPAIR TABLE Statement”, and Section 15.7.7.38, “SHOW TABLE STATUS Statement”.

附加资源Additional Resources