Skip to content

Commit bb45b6d

Browse files
committed
fix: tidb_index_serial_scan_concurrency
fix: v8.1 fix: v8.5 fix: tidb_analyze_distsql_scan_concurrency fix: tidb_index_serial_scan_concurrency fix: fix: 8.1 fix: 8.5 fix: update links fix: update fix fix: typo fix: update fix: default value fix: update fix: update fix: update fix: update
1 parent b760359 commit bb45b6d

File tree

7 files changed

+34
-29
lines changed

7 files changed

+34
-29
lines changed

best-practices/tidb-best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Lots of MySQL experience is also applicable to TiDB. It is noted that TiDB has i
130130

131131
* Ensure the order of results through indexes
132132

133-
You can use indexes to filter or sort data. Firstly, get row IDs according to the index order. Then, return the row content according to the return order of row IDs. In this way, the returned results are ordered according to the index column. It has been mentioned earlier that the model of scanning index and getting row is parallel + pipeline. If the row is returned according to the index order, a high concurrency between two queries does not reduce latency. Thus, the concurrency is low by default, but it can be modified through the [`tidb_index_serial_scan_concurrency`](/system-variables.md#tidb_index_serial_scan_concurrency) variable.
133+
You can use indexes to filter or sort data. Firstly, get row IDs according to the index order. Then, return the row content according to the return order of row IDs. In this way, the returned results are ordered according to the index column. It has been mentioned earlier that the model of scanning index and getting row is parallel + pipeline. If the row is returned according to the index order, a high concurrency between two queries does not reduce latency. Thus, the concurrency is low by default, but you can increase it by adjusting [`tidb_executor_concurrency`](/system-variables.md#tidb_executor_concurrency-new-in-v50).
134134

135135
* Reverse index scan
136136

sql-statements/sql-statement-show-variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mysql> SHOW GLOBAL VARIABLES LIKE 'tidb%';
3737
| tidb_backoff_weight | 2 |
3838
| tidb_batch_commit | 0 |
3939
| tidb_batch_delete | 0 |
40-
| tidb_build_stats_concurrency | 4 |
40+
| tidb_build_stats_concurrency | 2 |
4141
| tidb_capture_plan_baselines | off |
4242
| tidb_check_mb4_value_in_utf8 | 1 |
4343
| tidb_checksum_table_concurrency | 4 |
@@ -173,4 +173,4 @@ The `SHOW [GLOBAL|SESSION] VARIABLES` statement in TiDB is fully compatible with
173173

174174
## See also
175175

176-
* [`SET [GLOBAL|SESSION]`](/sql-statements/sql-statement-set-variable.md)
176+
* [`SET [GLOBAL|SESSION]`](/sql-statements/sql-statement-set-variable.md)

statistics.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -752,23 +752,21 @@ The relationships of the relevant system variables are shown below:
752752

753753
#### `tidb_build_stats_concurrency`
754754

755-
When you run the `ANALYZE` statement, the task is divided into multiple small tasks. Each task only works on statistics of one column or index. You can use the [`tidb_build_stats_concurrency`](/system-variables.md#tidb_build_stats_concurrency) variable to control the number of simultaneous small tasks. The default value is `2`. The default value is `4` for v7.4.0 and earlier versions.
755+
Used to control the concurrency of table or partition analysis — for example, how many partition or table tasks can be processed simultaneously. The default value is `2`. The default value is `4` for v7.4.0 and earlier versions.
756756

757757
#### `tidb_build_sampling_stats_concurrency`
758758

759-
When analyzing ordinary columns, you can use [`tidb_build_sampling_stats_concurrency`](/system-variables.md#tidb_build_sampling_stats_concurrency-new-in-v750) to control the concurrency of executing sampling tasks. The default value is `2`.
759+
1. Used to control the concurrency level for merging samples collected from different regions.
760+
2. Used to control the concurrency for special indexes (such as indexes on generated virtual columns), for example, how many special indexes can collect statistics simultaneously. The default value is `2`.
760761

761762
#### `tidb_analyze_partition_concurrency`
762763

763-
When running the `ANALYZE` statement, you can use [`tidb_analyze_partition_concurrency`](/system-variables.md#tidb_analyze_partition_concurrency) to control the concurrency of reading and writing statistics for a partitioned table. The default value is `2`. The default value is `1` for v7.4.0 and earlier versions.
764+
Used to control the concurrency for saving analyze results (writing TopN and histograms to system tables). The default value is `2`. The default value is `1` for v7.4.0 and earlier versions.
764765

765-
#### `tidb_distsql_scan_concurrency`
766+
#### `tidb_analyze_distsql_scan_concurrency`
766767

767-
When you analyze regular columns, you can use the [`tidb_distsql_scan_concurrency`](/system-variables.md#tidb_distsql_scan_concurrency) variable to control the number of Regions to be read at one time. The default value is `15`. Note that changing the value will affect query performance. Adjust the value carefully.
768-
769-
#### `tidb_index_serial_scan_concurrency`
770-
771-
When you analyze index columns, you can use the [`tidb_index_serial_scan_concurrency`](/system-variables.md#tidb_index_serial_scan_concurrency) variable to control the number of Regions to be read at one time. The default value is `1`. Note that changing the value will affect query performance. Adjust the value carefully.
768+
1. Used to control the concurrency of scanning TiKV regions.
769+
2. Used to control the concurrency of scanning regions for special indexes (indexes generated from virtual columns). The default value is `4`.
772770

773771
## See also
774772

system-variables.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,13 +1130,19 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a
11301130
11311131
### tidb_analyze_distsql_scan_concurrency <span class="version-mark">New in v7.6.0</span>
11321132
1133+
> **Note:**
1134+
>
1135+
> Before v7.6.0, it controlled by the variable `tidb_distsql_scan_concurrency`.
1136+
> So please consider change the value of `tidb_distsql_scan_concurrency` if you want to adjust the concurrency of scanning TiKV regions in versions earlier than v7.6.0.
1137+
11331138
- Scope: SESSION | GLOBAL
11341139
- Persists to cluster: Yes
11351140
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
11361141
- Type: Integer
11371142
- Default value: `4`
11381143
- Range: `[0, 4294967295]`. In versions earlier than v8.2.0, the minimum value is `1`. When you set it to `0`, it adaptively adjusts the concurrency based on the cluster size.
1139-
- This variable is used to set the concurrency of the `scan` operation when executing the `ANALYZE` operation.
1144+
- Used to control the concurrency of scanning TiKV regions.
1145+
- Used to control the concurrency of scanning regions for special indexes (indexes generated from virtual columns).
11401146
11411147
### tidb_analyze_partition_concurrency
11421148
@@ -1145,7 +1151,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a
11451151
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
11461152
- Default value: `2`. The default value is `1` for v7.4.0 and earlier versions.
11471153
- Range: `[1, 128]`. Before v8.4.0, the value range is `[1, 18446744073709551615]`.
1148-
- This variable specifies the concurrency for writing collected statistics when TiDB analyzes a partitioned table.
1154+
- For manual/auto analyze: used to control the concurrency for saving analyze results (writing TopN and histograms to system tables).
11491155
11501156
### tidb_analyze_version <span class="version-mark">New in v5.1.0</span>
11511157
@@ -1189,7 +1195,7 @@ mysql> SELECT @@tidb_analyze_skip_column_types;
11891195
+----------------------------------+
11901196
| @@tidb_analyze_skip_column_types |
11911197
+----------------------------------+
1192-
| json,blob,mediumblob,longblob |
1198+
| json,blob,mediumblob,longblob,text,mediumtext,longtext |
11931199
+----------------------------------+
11941200
1 row in set (0.00 sec)
11951201
@@ -1287,7 +1293,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;
12871293
- Type: Integer
12881294
- Default value: `1`
12891295
- Range: `[1, 256]`
1290-
- This variable is used to set the concurrency of executing the automatic update of statistics.
1296+
- For auto analyze: used to control the concurrency of table or partition analysis — for example, how many partition or table tasks can be processed simultaneously.
12911297

12921298
### tidb_backoff_lock_fast
12931299

@@ -1400,8 +1406,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;
14001406
- Default value: `2`. The default value is `4` for v7.4.0 and earlier versions.
14011407
- Range: `[1, 256]`
14021408
- Unit: Threads
1403-
- This variable is used to set the concurrency of executing the `ANALYZE` statement.
1404-
- When the variable is set to a larger value, the execution performance of other queries is affected.
1409+
- For manual analyze: used to control the concurrency of table or partition analysis — for example, how many partition or table tasks can be processed simultaneously.
14051410

14061411
### tidb_build_sampling_stats_concurrency <span class="version-mark">New in v7.5.0</span>
14071412

@@ -1412,8 +1417,8 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;
14121417
- Unit: Threads
14131418
- Default value: `2`
14141419
- Range: `[1, 256]`
1415-
- This variable is used to set the sampling concurrency in the `ANALYZE` process.
1416-
- When the variable is set to a larger value, the execution performance of other queries is affected.
1420+
- Used to control the concurrency level for merging samples collected from different regions.
1421+
- Used to control the concurrency for special indexes (such as indexes on generated virtual columns), for example, how many indexes can collect statistics simultaneously.
14171422

14181423
### tidb_capture_plan_baselines <span class="version-mark">New in v4.0</span>
14191424

@@ -3506,15 +3511,18 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified
35063511

35073512
### tidb_index_serial_scan_concurrency
35083513

3514+
> **Warning:**
3515+
>
3516+
> This variable is deprecated and cannot be modified. Sequential index scans now follow [`tidb_executor_concurrency`](#tidb_executor_concurrency-new-in-v50), and [`ANALYZE TABLE`](/sql-statements/sql-statement-analyze-table.md) uses [`tidb_analyze_distsql_scan_concurrency`](#tidb_analyze_distsql_scan_concurrency-new-in-v760) to control index read concurrency.
3517+
35093518
- Scope: SESSION | GLOBAL
35103519
- Persists to cluster: Yes
35113520
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes
35123521
- Type: Integer
35133522
- Default value: `1`
35143523
- Range: `[1, 256]`
35153524
- Unit: Threads
3516-
- This variable is used to set the concurrency of the `serial scan` operation.
3517-
- Use a bigger value in OLAP scenarios, and a smaller value in OLTP scenarios.
3525+
- This variable remains only for backward compatibility. Adjust [`tidb_executor_concurrency`](#tidb_executor_concurrency-new-in-v50) to affect sequential index scans, or [`tidb_analyze_distsql_scan_concurrency`](#tidb_analyze_distsql_scan_concurrency-new-in-v760) to tune index statistics collection.
35183526

35193527
### tidb_init_chunk_size
35203528

@@ -4035,7 +4043,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified
40354043
- Persists to cluster: Yes
40364044
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
40374045
- Default value: `1`
4038-
- This variable specifies the concurrency of merging statistics for a partitioned table when TiDB analyzes the partitioned table.
4046+
- Used to control the concurrency for merging TopN results of partitioned tables.
40394047

40404048
### tidb_enable_async_merge_global_stats <span class="version-mark">New in v7.5.0</span>
40414049

tidb-cloud/v8.1-performance-benchmarking-with-tpcc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ This section introduces how to perform the TPC-C performance test step by step.
9696

9797
```sql
9898
SET tidb_build_stats_concurrency=16;
99-
SET tidb_distsql_scan_concurrency=16;
100-
SET tidb_index_serial_scan_concurrency=16;
99+
SET tidb_build_sampling_stats_concurrency = 16;
100+
SET tidb_analyze_distsql_scan_concurrency=16;
101101
```
102102

103103
5. Run the following `go-tpc tpcc` command to conduct stress tests on the TiDB Cloud Dedicated cluster. For each concurrency, the test takes two hours.

tidb-cloud/v8.5-performance-benchmarking-with-tpcc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ This section introduces how to perform the TPC-C performance test step by step.
9696

9797
```sql
9898
SET tidb_build_stats_concurrency=16;
99-
SET tidb_distsql_scan_concurrency=16;
100-
SET tidb_index_serial_scan_concurrency=16;
99+
SET tidb_build_sampling_stats_concurrency = 16;
100+
SET tidb_analyze_distsql_scan_concurrency=16;
101101
```
102102

103103
5. Run the following `go-tpc tpcc` command to conduct stress tests on the TiDB Cloud Dedicated cluster. For each concurrency, the test takes two hours.

troubleshoot-tidb-oom.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ You can take the following measures to reduce the memory usage of SQL statements
9999
100100
- Reduce the number of Regions to be read simultaneously or reduce the concurrency of operators to avoid memory problems caused by high concurrency. The corresponding system variables include:
101101
- [`tidb_distsql_scan_concurrency`](/system-variables.md#tidb_distsql_scan_concurrency)
102-
- [`tidb_index_serial_scan_concurrency`](/system-variables.md#tidb_index_serial_scan_concurrency)
103102
- [`tidb_executor_concurrency`](/system-variables.md#tidb_executor_concurrency-new-in-v50)
104103
105104
- The concurrency of sessions is too high near the time point when the problem occurs. In this case, consider scaling out the TiDB cluster by adding more TiDB nodes.
@@ -195,4 +194,4 @@ To locate the root cause of an OOM issue, you need to collect the following info
195194
## See also
196195
197196
- [TiDB Memory Control](/configure-memory-usage.md)
198-
- [Tune TiKV Memory Parameter Performance](/tune-tikv-memory-performance.md)
197+
- [Tune TiKV Memory Parameter Performance](/tune-tikv-memory-performance.md)

0 commit comments

Comments
 (0)