Asynchronous I/O for DDL

Updated at:

PolarDB provides the asynchronous I/O for DDL feature. A Data Definition Language (DDL) operation that creates an index on a large database table is usually time-consuming. You can use asynchronous I/O for DDL to reduce the time required to create an index.

Prerequisites

PolarDB clusters must meet one of the following version requirements:

  • PolarDB for MySQL 8.0.2, with a revision version of 8.0.2.2.6 or later.

  • PolarDB for MySQL 8.0.1, with a revision version of 8.0.1.1.29 or later.

For more information about how to check the cluster version, see Query the engine version.

Notes

Asynchronous I/O for DDL is not supported for full-text indexes or spatial indexes.

Usage

You can configure asynchronous I/O for DDL by setting the following innodb_polar_ddl_async_io parameter. For instructions, see Set cluster parameters and node parameters.

Parameter

Level

Description

innodb_polar_ddl_async_io

Global

Specifies whether to enable asynchronous I/O for DDL. Valid values:

  • ON: Enables asynchronous I/O for DDL.

  • OFF: Disables asynchronous I/O for DDL. This is the default value.

Performance test

  • Test environment

    • A PolarDB for MySQL 8.0 cluster with 8 cores and 32 GB of memory.

    • The cluster has 50 TB of storage space.

  • Test table schema

    Run the following statement to create a table named table_1:

    CREATE TABLE `table_1` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `seller_id` bigint(20) DEFAULT NULL,
    `seller_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
    `gmt_create` varchar(30) DEFAULT NULL,
    `update_time` varchar(30) DEFAULT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB;
  • Test table data

    Run the following statements to generate test data:

    delimiter ||
    CREATE PROCEDURE populate_0(IN NUM INT)
    BEGIN
    DECLARE sid INT;
    DECLARE suffix_name INT;
    DECLARE i INT;
    SET sid=1000;
    SET suffix_name=10;
    SET i=1;
    START TRANSACTION;
    WHILE i <= NUM
    DO
    INSERT INTO table_1(seller_id,seller_name,gmt_create,update_time) VALUES(sid,CONCAT('sellername',suffix_name),NOW(),NOW());
    SET suffix_name=suffix_name+1;
    SET sid=sid+1;
    SET i=i+1;
    END WHILE;
    COMMIT;
    END ||
    delimiter ;
    CALL populate_0(100000000) ;
  • Test method and results

    After the data is inserted, run the SQL statement alter table table_1 add index name_index (seller_name); with asynchronous I/O for DDL enabled and disabled to measure the improvement in DDL execution efficiency:

    Asynchronous I/O for DDL status

    Time (seconds)

    Asynchronous I/O for DDL enabled

    368

    Asynchronous I/O for DDL disabled

    485

Contact us

If you have any questions about DDL operations, you can search for the DingTalk group number and join the group for consultation. You can directly @ the experts in the group with your questions. The group also has a PolarDB for MySQL assistant online 24/7 to answer your questions. DingTalk group number: 15375044501.