PolarDB supports the parallel data definition language (DDL) feature. When available hardware resources exist in a cluster, the parallel DDL feature can speed up the execution of DDL operations. This prevents subsequent DML operations from being blocked and shortens the execution windows of DDL operations.
When you create secondary indexes, the PolarDB cluster must meet one of the following requirements:
• PolarDB for MySQL 8.0.2 whose revision version is 8.0.2.1.7 or later.
• PolarDB for MySQL 8.0.1 whose revision version is 8.0.1.1.10 or later.
• PolarDB for MySQL 5.7 whose revision version is 5.7.1.0.7 or later.
When you create primary indexes, the PolarDB cluster must meet one of the following requirements:
• PolarDB for MySQL 8.0.2 whose revision version is 8.0.2.2.9 or later.
• PolarDB for MySQL 8.0.1 whose revision version is 8.0.1.1.31 or later.
The parallel DDL feature can accelerate only the DDL operations that are used to create primary key indexes and secondary indexes. The secondary indexes exclude full-text indexes, spatial indexes, and the secondary indexes on virtual columns.
Specify the number of concurrent threads for each DDL operation: You can enable the parallel DDL feature by specifying the innodb_polar_parallel_ddl_threads parameter:
Table structure, table data volume, and index before creating secondary indexes
The table has 22,000,004 rows of data.
Table creation statement: Table creation statement.sql
innodb_polar_parallel_ddl_threads is not enabled.
Description: The number of concurrent threads for each DDL operation. Valid values: 1 to 16. The default value 1 indicates that single-threaded DDL operations are executed. If the value of this parameter is not 1 and when you create secondary indexes, the parallel DDL feature is automatically enabled.
Index creation statement:
ALTER TABLE `sys_user` ADD KEY `index_phone`(`phonenumber`);
Creating indexes without enabling parallel DDL takes: 93,979 ms
Enable: innodb_polar_parallel_ddl_threads is changed to 16
To optimize the tablespace before adding indexes again, please execute: optimize table sys_user;
Index addition statement:
ALTER TABLE `sys_user` ADD KEY `index_phone`(`phonenumber`);
Create with parallel DDL enabled took 72,255 ms.
ApsaraDB - January 7, 2025
ApsaraDB - August 23, 2024
ApsaraDB - June 26, 2025
ApsaraDB - July 7, 2021
ApsaraDB - November 12, 2024
ApsaraDB - September 19, 2022
Alibaba Cloud PolarDB for MySQL is a cloud-native relational database service 100% compatible with MySQL.
Learn MoreAlibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn MoreAlibaba Cloud PolarDB for Xscale (PolarDB-X) is a cloud-native high-performance distributed database service independently developed by Alibaba Cloud.
Learn MoreMigrating to fully managed cloud databases brings a host of benefits including scalability, reliability, and cost efficiency.
Learn MoreMore Posts by ApsaraDB