Chapter 24 Partitioning第24章 分区

Table of Contents

24.1 Overview of Partitioning in MySQLMySQL分区概述
24.2 Partitioning Types分区类型
24.2.1 RANGE PartitioningRANGE分区
24.2.2 LIST PartitioningLIST分区
24.2.3 COLUMNS PartitioningCOLUMNS分区
24.2.4 HASH PartitioningHASH分区
24.2.5 KEY PartitioningKEY分区
24.2.6 Subpartitioning细分
24.2.7 How MySQL Partitioning Handles NULLMySQL分区如何处理NULL
24.3 Partition Management分区管理
24.3.1 Management of RANGE and LIST PartitionsRANGE和LIST分区的管理
24.3.2 Management of HASH and KEY PartitionsHASH和KEY分区的管理
24.3.3 Exchanging Partitions and Subpartitions with Tables用表交换分区和子分区
24.3.4 Maintenance of Partitions隔板的维护
24.3.5 Obtaining Information About Partitions获取分区信息
24.4 Partition Pruning分区修剪
24.5 Partition Selection分区选择
24.6 Restrictions and Limitations on Partitioning分区的限制和限制
24.6.1 Partitioning Keys, Primary Keys, and Unique Keys分区键、主键和唯一键
24.6.2 Partitioning Limitations Relating to Storage Engines与存储引擎相关的分区限制
24.6.3 Partitioning Limitations Relating to Functions与函数相关的分区限制

This chapter discusses user-defined partitioning.本章讨论用户定义的分区。

Note注意

Table partitioning differs from partitioning as used by window functions. For information about window functions, see Section 12.21, “Window Functions”.表分区与窗口函数使用的分区不同。有关窗口功能的信息,请参阅第12.21节,“窗口函数”

In MySQL 8.0, partitioning support is provided by the InnoDB and NDB storage engines.在MySQL 8.0中,分区支持由InnoDB和NDB存储引擎提供。

MySQL 8.0 does not currently support partitioning of tables using any storage engine other than InnoDB or NDB, such as MyISAM. MySQL 8.0目前不支持使用InnoDB或NDB以外的任何存储引擎(如MyISAM)对表进行分区。An attempt to create a partitioned tables using a storage engine that does not supply native partitioning support fails with ER_CHECK_NOT_IMPLEMENTED.尝试使用不提供本机分区支持的存储引擎创建分区表时失败,返回ER_CHECK_not_IMPLEMENTED。

MySQL 8.0 Community binaries provided by Oracle include partitioning support provided by the InnoDB and NDB storage engines. Oracle提供的MySQL 8.0社区二进制文件包括InnoDBNDB存储引擎提供的分区支持。For information about partitioning support offered in MySQL Enterprise Edition binaries, see Chapter 30, MySQL Enterprise Edition.有关MySQL Enterprise Edition二进制文件中提供的分区支持的信息,请参阅第30章,“MySQL企业版”

If you are compiling MySQL 8.0 from source, configuring the build with InnoDB support is sufficient to produce binaries with partition support for InnoDB tables. 如果您是从源代码编译MySQL 8.0,那么使用InnoDB支持配置构建就足以生成支持InnoDB表分区的二进制文件。For more information, see Section 2.9, “Installing MySQL from Source”.有关更多信息,请参阅第2.9节,“从源代码安装MySQL”

Nothing further needs to be done to enable partitioning support by InnoDB (for example, no special entries are required in the my.cnf file).不需要做任何进一步的事情来启用InnoDB的分区支持(例如,my.cnf文件中不需要特殊的条目)。

It is not possible to disable partitioning support by the InnoDB storage engine.InnoDB存储引擎不可能禁用分区支持。

See Section 24.1, “Overview of Partitioning in MySQL”, for an introduction to partitioning and partitioning concepts.有关分区和分区概念的介绍,请参阅第24.1节,“MySQL中的分区概述”

Several types of partitioning are supported, as well as subpartitioning; see Section 24.2, “Partitioning Types”, and Section 24.2.6, “Subpartitioning”.支持多种类型的分区以及子分区;参见第24.2节,“分区类型”第24.2.6节,“细分”

Section 24.3, “Partition Management”, covers methods of adding, removing, and altering partitions in existing partitioned tables.第24.3节,“分区管理”涵盖了在现有分区表中添加、删除和更改分区的方法。

Section 24.3.4, “Maintenance of Partitions”, discusses table maintenance commands for use with partitioned tables.第24.3.4节,“分区的维护”讨论了用于分区表的表维护命令。

The PARTITIONS table in the INFORMATION_SCHEMA database provides information about partitions and partitioned tables. INFORMATION_SCHEMA数据库中的PARTITIONS表提供了有关分区和分区表的信息。See Section 26.3.21, “The INFORMATION_SCHEMA PARTITIONS Table”, for more information; for some examples of queries against this table, see Section 24.2.7, “How MySQL Partitioning Handles NULL”.有关更多信息,请参阅第26.3.21节,“INFORMATION_SCHEMA PARTITIONS表”;有关针对该表的一些查询示例,请参阅第24.2.7节,“MySQL分区如何处理NULL

For known issues with partitioning in MySQL 8.0, see Section 24.6, “Restrictions and Limitations on Partitioning”.有关MySQL 8.0中分区的已知问题,请参阅第24.6节,“分区的限制和限制”

You may also find the following resources to be useful when working with partitioned tables.在处理分区表时,您可能还会发现以下资源非常有用。

Additional Resources.额外资源。  Other sources of information about user-defined partitioning in MySQL include the following:MySQL中有关用户定义分区的其他信息来源包括:

24.1 Overview of Partitioning in MySQL
24.2 Partitioning Types
24.3 Partition Management
24.4 Partition Pruning
24.5 Partition Selection
24.6 Restrictions and Limitations on Partitioning