文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 17 InnoDB 存储引擎 / 17.1 InnoDB 简介 / 17.1.1 使用 InnoDB 表的好处
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

17.1.1 使用 InnoDB 表的好处17.1.1 Benefits of Using InnoDB Tables

InnoDB 表具有以下好处:InnoDB tables have the following benefits:

  • 如果服务器因硬件或软件问题意外退出,无论当时数据库中发生了什么,在重新启动数据库后,您无需做任何特殊操作。InnoDB 崩溃恢复会自动完成在崩溃前已提交的更改,并撤销正在进行但未提交的更改,使您可以从中断处重新启动并继续操作。参见 第 17.18.2 节,“InnoDB 恢复”。If the server unexpectedly exits because of a hardware or software issue, regardless of what was happening in the database at the time, you don't need to do anything special after restarting the database. InnoDB crash recovery automatically finalizes changes that were committed before the time of the crash, and undoes changes that were in process but not committed, permitting you to restart and continue from where you left off. See Section 17.18.2, “InnoDB Recovery”.

  • InnoDB 存储引擎维护自己的缓冲池,将表和索引数据在访问时缓存在主存中。经常使用的数据可以直接从内存中处理。这种缓存适用于多种类型的信息并加快处理速度。在专用数据库服务器上,通常将高达 80% 的物理内存分配给缓冲池。参见 第 17.5.1 节,“缓冲池”。The InnoDB storage engine maintains its own buffer pool that caches table and index data in main memory as data is accessed. Frequently used data is processed directly from memory. This cache applies to many types of information and speeds up processing. On dedicated database servers, up to 80% of physical memory is often assigned to the buffer pool. See Section 17.5.1, “Buffer Pool”.

  • 如果将相关数据拆分到不同的表中,可以设置外键来强制执行引用完整性。参见 第 15.1.20.5 节,“FOREIGN KEY 约束”。If you split up related data into different tables, you can set up foreign keys that enforce referential integrity. See Section 15.1.20.5, “FOREIGN KEY Constraints”.

  • 如果数据在磁盘或内存中损坏,校验和机制会在您使用数据之前提醒您数据有误。innodb_checksum_algorithm 变量定义了 InnoDB 使用的校验和算法。If data becomes corrupted on disk or in memory, a checksum mechanism alerts you to the bogus data before you use it. The innodb_checksum_algorithm variable defines the checksum algorithm used by InnoDB.

  • 当你为每个表设计了适当的主键列时,涉及这些列的操作会自动得到优化。在 WHERE 子句、ORDER BY 子句、GROUP BY 子句以及连接操作中引用主键列的速度非常快。请参阅 第 17.6.2.1 节,“聚簇索引和二级索引”。When you design a database with appropriate primary key columns for each table, operations involving those columns are automatically optimized. It is very fast to reference the primary key columns in WHERE clauses, ORDER BY clauses, GROUP BY clauses, and join operations. See Section 17.6.2.1, “Clustered and Secondary Indexes”.

  • 插入、更新和删除操作通过一种称为变更缓冲的自动机制进行优化。InnoDB 不仅允许对同一表进行并发读写访问,还缓存已更改的数据以简化磁盘 I/O。参见 第 17.5.2 节,“Change Buffer”。Inserts, updates, and deletes are optimized by an automatic mechanism called change buffering. InnoDB not only allows concurrent read and write access to the same table, it caches changed data to streamline disk I/O. See Section 17.5.2, “Change Buffer”.

  • 性能优势不仅限于具有长时间运行查询的大型表。当从表中反复访问相同的行时,自适应哈希索引(Adaptive Hash Index)会接管,使这些查找速度更快,就像来自哈希表一样。参见 第 17.5.3 节,“Adaptive Hash Index”。Performance benefits are not limited to large tables with long-running queries. When the same rows are accessed over and over from a table, the Adaptive Hash Index takes over to make these lookups even faster, as if they came out of a hash table. See Section 17.5.3, “Adaptive Hash Index”.

  • 您可以压缩表及其相关索引。参见 第 17.9 节,“InnoDB 表和页面压缩”。You can compress tables and associated indexes. See Section 17.9, “InnoDB Table and Page Compression”.

  • 您可以加密您的数据。请参见 第 17.13 节,“InnoDB 数据静态加密”。You can encrypt your data. See Section 17.13, “InnoDB Data-at-Rest Encryption”.

  • 您可以创建和删除索引以及执行其他 DDL 操作,对性能和可用性的影响要小得多。请参见 第 17.12.1 节,“在线 DDL 操作”。You can create and drop indexes and perform other DDL operations with much less impact on performance and availability. See Section 17.12.1, “Online DDL Operations”.

  • 截断每表文件表空间非常快速,并且可以释放磁盘空间供操作系统重用,而不仅仅是 InnoDB 使用。请参见 第 17.6.3.2 节,“每表文件表空间”。Truncating a file-per-table tablespace is very fast and can free up disk space for the operating system to reuse rather than only InnoDB. See Section 17.6.3.2, “File-Per-Table Tablespaces”.

  • 使用 DYNAMIC 行格式,表数据的存储布局对于 BLOB 和长文本字段更加高效。参见 第 17.10 节,“InnoDB 行格式”。The storage layout for table data is more efficient for BLOB and long text fields, with the DYNAMIC row format. See Section 17.10, “InnoDB Row Formats”.

  • 您可以通过查询 INFORMATION_SCHEMA 表来监控存储引擎的内部工作。参见 第 17.15 节,“InnoDB INFORMATION_SCHEMA 表”。You can monitor the internal workings of the storage engine by querying INFORMATION_SCHEMA tables. See Section 17.15, “InnoDB INFORMATION_SCHEMA Tables”.

  • 您可以通过查询 Performance Schema 表来监控存储引擎的性能详情。参见 第 17.16 节,“InnoDB 与 MySQL Performance Schema 集成”。You can monitor the performance details of the storage engine by querying Performance Schema tables. See Section 17.16, “InnoDB Integration with MySQL Performance Schema”.

  • 您可以将 InnoDB 表与其他 MySQL 存储引擎的表混合使用,甚至在同一个语句中。例如,您可以使用 join 操作在单个查询中组合 InnoDB 表和 MEMORY 表的数据。You can mix InnoDB tables with tables from other MySQL storage engines, even within the same statement. For example, you can use a join operation to combine data from InnoDB and MEMORY tables in a single query.

  • InnoDB 的设计旨在在处理大量数据时实现 CPU 效率和最大性能。InnoDB has been designed for CPU efficiency and maximum performance when processing large data volumes.

  • InnoDB 表可以处理大量数据,即使在文件大小受限为 2GB 的操作系统上也是如此。InnoDB tables can handle large quantities of data, even on operating systems where file size is limited to 2GB.

有关可以应用于 MySQL 服务器和应用程序代码的 InnoDB 特定调优技术,请参见 第 10.5 节,“针对 InnoDB 表的优化”。For InnoDB-specific tuning techniques you can apply to your MySQL server and application code, see Section 10.5, “Optimizing for InnoDB Tables”.