# Analyze Concurrency Control


![left](./student-guide/diagram/18-Control-ANALYZE-concurrency-01-01.png)

------------------------------------------------------------
When executing the ANALYZE statement, you can adjust the concurrency or the number of regions of the operation with some parameters to balance the load and execution performance of the TiDB cluster.

- tidb_build_stats_concurrency
  - Currently, when ANALYZE is executed, it is divided into small tasks. Each task is responsible for only one column or index. Adjust this parameter to control the number of tasks that are executed at the same time.
  - If the number of indexes on a table is 4, you need to collect column and 4 index statistics, in the case of 4 concurrent collection threads, there must be a statistics collection in pending state, you need to wait for other statistics to be collected before collecting this statistics, which is equivalent to 2 times the statistics collection time, at this time if you adjust the parallelism of this parameter to 5, you can do it at the same time Collect all statistics for this table, saving time for statistics collection.
  - Note: When this variable is set larger, it will have a certain impact on the SQL execution performance of the cluster

- tidb_distsql_scan_concurrency
  - This variable is used to set the concurrency of scan operations. OLAP-class applications are suitable for large values, and OLTP-class applications are suitable for small values. For OLAP applications, the maximum value is not recommended to exceed the number of CPU cores for all TiKV nodes.
  - When performing the Analyze Common Columns task, increasing this parameter can be used to control the number of regions to read at one time.
  - Note: This parameter is not dedicated to statistics collection. Adjusting this parameter will affect all SQL operations involving Scan.

- tidb_index_serial_scan_concurrency
  - This variable is used to set the concurrency of sequential scan operations. Large values are appropriate for OLAP class applications and small values for OLTP class applications.
  - Since the index itself is ordered, adjusting this parameter can be used to control the number of regions in one read when performing the Analyze Index column task.
  - Note: When these variables are set larger, it will have a certain impact on the SQL execution performance of the cluster.
