tencent cloud

TDSQL Boundless

DDL Operation Guide

PDF
フォーカスモード
フォントサイズ
最終更新日: 2026-02-10 11:28:03

Pre-operation check

1. Confirm whether there is sufficient space to perform DDL operations.
View the space currently occupied by the table for DDL operations and determine whether there is sufficient space for DDL operations based on the disk utilization of the current instance.
SELECT
table_name AS 'table name',
ROUND((data_length + index_length) / 1024 / 1024, 2) AS 'total space (MB)',
ROUND(data_length / 1024 / 1024, 2) AS 'Data Storage (MB)',
ROUND(index_length / 1024 / 1024, 2) AS 'Index Space (MB)',
ROUND(data_free / 1024 / 1024, 2) AS 'Fragmented Space (MB)'
FROM information_schema.TABLES
WHERE table_schema = 'database name'
AND table_name = 'table name';
Note:
Some DDL operations can use instant DDL without occupying space. For details, see OnlineDDL description.
2. To check whether there are slow queries with excessively long data in tables with the same name.
SELECT * FROM information_schema.processlist WHERE INFO LIKE "%table name%" ORDER BY TIME_MS DESC LIMIT 10;
If any exist, wait for the slow queries to complete before the DDL is executed.
3. For large single tables, examine the data distribution to confirm I/O pressure.
SELECT
SUM(region_stats_approximate_size) AS size,
COUNT(b.rep_group_id) AS region_nums,
sql_addr,
c.leader_node_name,
b.rep_group_id
FROM
information_schema.META_CLUSTER_DATA_OBJECTS a
JOIN information_schema.META_CLUSTER_REGIONS b
JOIN information_schema.META_CLUSTER_RGS c
JOIN information_schema.META_CLUSTER_NODES d
ON a.data_obj_id = b.data_obj_id
AND b.rep_group_id = c.rep_group_id
AND c.leader_node_name = d.node_name
WHERE
a.schema_name = 'database name'
AND a.table_name = 'table name'
GROUP BY
rep_group_id
ORDER BY
leader_node_name;
If data is entirely skewed on a single node, it is recommended to set max_parallel_ddl_degree from the default value of 8 to 4 or 2, reducing the number of concurrent DDL threads to alleviate I/O pressure.
4. By monitoring metrics on the tenant side, confirm CPU/I/O load.
It is recommended to perform DDL operations during off-peak business hours.

View Progress During Operation

-- Check the execution status of the DDL; if LAST_TIMESTAMP is updating, the DDL is in progress. If no update occurs for a long time, it may be stuck.
SELECT * FROM information_schema.ddl_jobs WHERE is_history = 0;

-- To check the progress, focus on the "progress" information in the INFO field of information_Schema.ddl_jobs.
ID: 13
SCHEMA_NAME: tdstore
TABLE_NAME: sbtest1
VERSION: 13
DDL_STATUS: SUCCESS
START_TIMESTAMP: 2025-08-08 14:29:35
LAST_TIMESTAMP: 2025-08-08 14:29:35
DDL_SQL: alter table tdstore.sbtest1 add index idx(v)
INFO_TYPE: ALTER TABLE
INFO: {"tmp_tbl":{"db":"tdstore","table":"#sql-d_1000be_6895994e0000ad_1"},"alt_type":1,"alt_tid_upd":{"tid_from":10039,"tid_to":10039},"cr_idx":[{"id":10040,"ver":4,"stat":0,"tbl_type":1,"idx_type":2}],"rm_idx":[],"init":false,"tmp_tab":false,"online_op":true,"wf_rmed":false,"online_copy_stage":0,"idx_op":true,"row_applied":true,"row_apply_saved":true,"current_schema_name":"tdstore","crt_data_obj_task_id":29437883249066288,"dstr_data_obj_task_id":0,"alt_tbl_pp_stage":0,"alt_tbl_policy_option":0,"data_obj_to_be_dstr_arr":[],"progress":"total: 1, scanned: 1 (100.00%)","fillback_mode":"ThomasWrite","exec_addr":{"ip":"10.10.10.10","port":15035},"recov_addr":{"ip":"10.10.10.10","port":15035}}
IS_HISTORY: 1

-- Observe CPU/I/O load and slow query alarms through the tenant side;
INFO field's progress indicates the progress: "progress":"total: 1, scanned: 1 (100.00%)"

View Task Results

-- If it returns empty, it indicates that the DDL job has completed.
SELECT * FROM information_schema.ddl_jobs WHERE is_history = 0;

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック