创建或重建二级索引的在线 DDL 操作的工作流程包括:The workflow of an online DDL operation that creates or rebuilds a secondary index involves:
扫描聚簇索引并将数据写入临时排序文件Scanning the clustered index and writing data to temporary sort files
对数据进行排序Sorting the data
将临时排序文件中的已排序数据加载到二级索引中Loading sorted data from the temporary sort files into the secondary index
用于扫描聚簇索引的并行线程数由 innodb_parallel_read_threads 变量定义。默认设置是根据系统上可用的逻辑处理器数量除以 8 来计算,最小默认值为 4。最大设置为 256,这是所有会话的最大线程数。实际用于扫描聚簇索引的线程数是 innodb_parallel_read_threads 设置的值或需要扫描的索引子树数,以较小者为准。如果达到线程限制,会话将回退到使用单线程。The number of parallel threads that can be used to scan clustered
index is defined by the
innodb_parallel_read_threads
variable. The default setting is calculated by the number of
available logical processors on the system divided by 8, with a
minimum default value of 4. The maximum setting is 256, which is
the maximum number for all sessions. The actual number of threads
that scan the clustered index is the number defined by the
innodb_parallel_read_threads
setting or the number of index subtrees to scan, whichever is
smaller. If the thread limit is reached, sessions fall back to
using a single thread.
用于排序和加载数据的并行线程数由 innodb_ddl_threads 变量控制。默认设置为 4。The number of parallel threads that sort and load data is
controlled by the
innodb_ddl_threads variable. The
default setting is 4.
适用以下限制:The following limitations apply:
对于包含虚拟列的索引构建,不支持并行线程。Parallel threads are not supported for building indexes that include virtual columns.
不支持使用并行线程创建全文索引。Parallel threads are not supported for full-text index creation.
不支持使用并行线程创建空间索引。Parallel threads are not supported for spatial index creation.
对于定义了虚拟列的表,不支持并行扫描。Parallel scan is not supported on tables defined with virtual columns.
对于定义了全文索引的表,不支持并行扫描。Parallel scan is not supported on tables defined with a full-text index.
对于定义了空间索引的表,不支持并行扫描。Parallel scan is not supported on tables defined with a spatial index.