From 04b32243d055742b81c2d13aafe0d7f251baacb3 Mon Sep 17 00:00:00 2001 From: Frank945946 <108602632+Frank945946@users.noreply.github.com> Date: Mon, 22 Sep 2025 21:06:03 +0800 Subject: [PATCH 1/5] Update system-variables tidb_ddl_reorg_batch_size and tidb_ddl_reorg_worker_cnt --- system-variables.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system-variables.md b/system-variables.md index d6bd2b52f1e0a..6be67bd48483e 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1727,6 +1727,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - If `tidb_ddl_enable_fast_reorg` is set to `OFF`, `ADD INDEX` is executed as a transaction. If there are many update operations such as `UPDATE` and `REPLACE` in the target columns during the `ADD INDEX` execution, a larger batch size indicates a larger probability of transaction conflicts. In this case, it is recommended that you set the batch size to a smaller value. The minimum value is 32. - If the transaction conflict does not exist, or if `tidb_ddl_enable_fast_reorg` is set to `ON`, you can set the batch size to a large value. This makes data backfilling faster but also increases the write pressure on TiKV. For a proper batch size, you also need to refer to the value of `tidb_ddl_reorg_worker_cnt`. See [Interaction Test on Online Workloads and `ADD INDEX` Operations](https://docs.pingcap.com/tidb/dev/online-workloads-and-add-index-operations) for reference. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. + - Starting from v8.5.0, this parameter can be modified with ADMIN ALTER DDL JOBS BATCH_SIZE = ; (not supported for Add Index DDL when [tidb_enable_dist_task](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled). For details, see [ADMIN ALTER DDL JOBS](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs) ### tidb_ddl_reorg_priority @@ -1778,6 +1779,7 @@ Assume that you have a cluster with 4 TiDB nodes and multiple TiKV nodes. In thi - Unit: Threads - This variable is used to set the concurrency of the DDL operation in the `re-organize` phase. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. +- Starting from v8.5.0, this parameter can be modified with `ADMIN ALTER DDL JOBS THREAD = ;` (not supported for Add Index DDL when [tidb_enable_dist_task](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled). For details, see [ADMIN ALTER DDL JOBS](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs) ### `tidb_enable_fast_create_table` New in v8.0.0 From a54978e10f1e614f484e63f2e0bc4c8fe65a39f9 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Mon, 22 Sep 2025 21:09:12 +0800 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 6be67bd48483e..fb9a3e667297a 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1727,7 +1727,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - If `tidb_ddl_enable_fast_reorg` is set to `OFF`, `ADD INDEX` is executed as a transaction. If there are many update operations such as `UPDATE` and `REPLACE` in the target columns during the `ADD INDEX` execution, a larger batch size indicates a larger probability of transaction conflicts. In this case, it is recommended that you set the batch size to a smaller value. The minimum value is 32. - If the transaction conflict does not exist, or if `tidb_ddl_enable_fast_reorg` is set to `ON`, you can set the batch size to a large value. This makes data backfilling faster but also increases the write pressure on TiKV. For a proper batch size, you also need to refer to the value of `tidb_ddl_reorg_worker_cnt`. See [Interaction Test on Online Workloads and `ADD INDEX` Operations](https://docs.pingcap.com/tidb/dev/online-workloads-and-add-index-operations) for reference. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. - - Starting from v8.5.0, this parameter can be modified with ADMIN ALTER DDL JOBS BATCH_SIZE = ; (not supported for Add Index DDL when [tidb_enable_dist_task](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled). For details, see [ADMIN ALTER DDL JOBS](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs) + - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). ### tidb_ddl_reorg_priority @@ -1779,7 +1779,7 @@ Assume that you have a cluster with 4 TiDB nodes and multiple TiKV nodes. In thi - Unit: Threads - This variable is used to set the concurrency of the DDL operation in the `re-organize` phase. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. -- Starting from v8.5.0, this parameter can be modified with `ADMIN ALTER DDL JOBS THREAD = ;` (not supported for Add Index DDL when [tidb_enable_dist_task](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled). For details, see [ADMIN ALTER DDL JOBS](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs) +- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). ### `tidb_enable_fast_create_table` New in v8.0.0 From 4471f77d16581d5ed83bc0f32515e3cb00576f6d Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 24 Sep 2025 14:53:27 +0800 Subject: [PATCH 3/5] Apply suggestions from code review --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index fb9a3e667297a..8f3cdd6cc345c 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1727,7 +1727,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - If `tidb_ddl_enable_fast_reorg` is set to `OFF`, `ADD INDEX` is executed as a transaction. If there are many update operations such as `UPDATE` and `REPLACE` in the target columns during the `ADD INDEX` execution, a larger batch size indicates a larger probability of transaction conflicts. In this case, it is recommended that you set the batch size to a smaller value. The minimum value is 32. - If the transaction conflict does not exist, or if `tidb_ddl_enable_fast_reorg` is set to `ON`, you can set the batch size to a large value. This makes data backfilling faster but also increases the write pressure on TiKV. For a proper batch size, you also need to refer to the value of `tidb_ddl_reorg_worker_cnt`. See [Interaction Test on Online Workloads and `ADD INDEX` Operations](https://docs.pingcap.com/tidb/dev/online-workloads-and-add-index-operations) for reference. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. - - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). + - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). ### tidb_ddl_reorg_priority @@ -1779,7 +1779,7 @@ Assume that you have a cluster with 4 TiDB nodes and multiple TiKV nodes. In thi - Unit: Threads - This variable is used to set the concurrency of the DDL operation in the `re-organize` phase. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. -- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](system-variables/#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). +- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). ### `tidb_enable_fast_create_table` New in v8.0.0 From a308a5bc35292e22d6e542ca47e044d1d11f68d8 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 24 Sep 2025 14:55:45 +0800 Subject: [PATCH 4/5] Apply suggestions from code review --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 8f3cdd6cc345c..8c84e3da676dc 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1727,7 +1727,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - If `tidb_ddl_enable_fast_reorg` is set to `OFF`, `ADD INDEX` is executed as a transaction. If there are many update operations such as `UPDATE` and `REPLACE` in the target columns during the `ADD INDEX` execution, a larger batch size indicates a larger probability of transaction conflicts. In this case, it is recommended that you set the batch size to a smaller value. The minimum value is 32. - If the transaction conflict does not exist, or if `tidb_ddl_enable_fast_reorg` is set to `ON`, you can set the batch size to a large value. This makes data backfilling faster but also increases the write pressure on TiKV. For a proper batch size, you also need to refer to the value of `tidb_ddl_reorg_worker_cnt`. See [Interaction Test on Online Workloads and `ADD INDEX` Operations](https://docs.pingcap.com/tidb/dev/online-workloads-and-add-index-operations) for reference. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. - - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). + - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl.md#admin-alter-ddl-jobs). ### tidb_ddl_reorg_priority @@ -1779,7 +1779,7 @@ Assume that you have a cluster with 4 TiDB nodes and multiple TiKV nodes. In thi - Unit: Threads - This variable is used to set the concurrency of the DDL operation in the `re-organize` phase. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. -- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl/#admin-alter-ddl-jobs). +- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl.md#admin-alter-ddl-jobs). ### `tidb_enable_fast_create_table` New in v8.0.0 From 4d999af13fdc1080621cd410b725b76f6d62eb7e Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 24 Sep 2025 14:56:49 +0800 Subject: [PATCH 5/5] Apply suggestions from code review --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 8c84e3da676dc..f430c634edda5 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1727,7 +1727,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - If `tidb_ddl_enable_fast_reorg` is set to `OFF`, `ADD INDEX` is executed as a transaction. If there are many update operations such as `UPDATE` and `REPLACE` in the target columns during the `ADD INDEX` execution, a larger batch size indicates a larger probability of transaction conflicts. In this case, it is recommended that you set the batch size to a smaller value. The minimum value is 32. - If the transaction conflict does not exist, or if `tidb_ddl_enable_fast_reorg` is set to `ON`, you can set the batch size to a large value. This makes data backfilling faster but also increases the write pressure on TiKV. For a proper batch size, you also need to refer to the value of `tidb_ddl_reorg_worker_cnt`. See [Interaction Test on Online Workloads and `ADD INDEX` Operations](https://docs.pingcap.com/tidb/dev/online-workloads-and-add-index-operations) for reference. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. - - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl.md#admin-alter-ddl-jobs). + - Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS BATCH_SIZE = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md). ### tidb_ddl_reorg_priority @@ -1779,7 +1779,7 @@ Assume that you have a cluster with 4 TiDB nodes and multiple TiKV nodes. In thi - Unit: Threads - This variable is used to set the concurrency of the DDL operation in the `re-organize` phase. - Starting from v8.3.0, this parameter is supported at the SESSION level. Modifying the parameter at the GLOBAL level will not impact currently running DDL statements. It will only apply to DDLs submitted in new sessions. -- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statement-admin-alter-ddl.md#admin-alter-ddl-jobs). +- Starting from v8.5.0, you can modify this parameter for a running DDL job by executing `ADMIN ALTER DDL JOBS THREAD = ;`. Note that this operation is not supported for `ADD INDEX` DDL when [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is enabled. For details, see [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md). ### `tidb_enable_fast_create_table` New in v8.0.0