# Dynamically Adjust The Index Creation Speed 


![left](./student-guide/diagram/19-Speed-of-index-creation-01-01.png)

------------------------------------------------------------
Dynamically adjust the speed at which indexes are created

Since creating an index consumes a lot of resources while scanning a table to backfill the index, normal business is affected by collisions with some frequently updated column. The process of creating indexes on large tables tends to take a long time, so balance execution time with cluster performance as possible.

Currently, the two parameters tidb_ddl_reorg_worker_cnt and tidb_ddl_reorg_batch_size are mainly used to dynamically adjust the index creation speed. Generally speaking, the smaller their value, the less the impact on the system, but the longer the execution time.

Based on previous experience, we can first keep the values at the default of 4 and 256, observe the cluster resource usage and response speed, and then gradually increase the tidb_ddl_reorg_worker_cnt parameter to increase concurrency, and observe that if the system does not experience significant jitter, then gradually increase the monitoring. tidb_ddl_reorg_batch_size parameter, but if the column involved in the index is updated frequently, it will cause a large number of collisions and fail retries. 2

You can also increase speed by adjusting tidb_ddl_reorg_priority to PRIORITY_HIGH to keep the indexing task at a high priority, but on general-purpose OLTP systems, it is generally recommended to leave the default.
Evaluate the speed of index creation

When creating an index online, there are two things we need to keep an eye on:
- One is the pressure on the system to create an index. We can check the pressure of the system through Grafana's dashboard
- One is the speed of index creation. When the system is not stressed, we can adjust the speed of index creation appropriately
In the image above, we can refresh the admin show ddl to see how many rows of data have been processed. Select count (*) allows you to see the number of rows in the indexed table to estimate the current progress.

Control the concurrency of index creation
Control the amount of index data created at a time
Adjust the priority of index creation. The parameters are PRIORITY_LOW/PRIORITY_NORMAL/PRIORITY_HIGH
Number of failed retries before creating an index will fail

