TiDB version 6.1
Session 1 is creating an index on a table with 1 billion rows.
Session 2 is creating an index on an empty partitioned table.
Session 2 is taking a very long time to complete. How can I determine what resources session 2 is waiting for?
When multiple DDL statements are executed together, the latter DDL statements will be relatively slow. The reason is that in the current TiDB cluster, DDL operations are executed serially.
In TiDB’s architecture design, DDL is placed in a queue and executed in turn by multiple owners in a serial manner. Therefore, you can open another session to check the status of the executing job and make a judgment.
In our production environment, we have records of adding indexes that took more than 24 hours to execute.
First, check what the previous poster mentioned, admin show ddl jobs to view the progress status of the DDL. If you want to speed it up, you can modify the parameter: SET GLOBAL tidb_ddl_reorg_worker_cnt=16; This temporarily and dynamically adjusts the concurrency, increasing the index addition speed by a hundredfold.
This parameter defaults to 4.