Skip to content

Commit b5780fe

Browse files
Spill of parallel aggregation in TiDB (#15755)
1 parent 1966294 commit b5780fe

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

configure-memory-usage.md

+3-11
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ TiDB supports disk spill for execution operators. When the memory usage of a SQL
149149

150150
- The disk spill behavior is jointly controlled by the following parameters: [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query), [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom), [`tmp-storage-path`](/tidb-configuration-file.md#tmp-storage-path), and [`tmp-storage-quota`](/tidb-configuration-file.md#tmp-storage-quota).
151151
- When the disk spill is triggered, TiDB outputs a log containing the keywords `memory exceeds quota, spill to disk now` or `memory exceeds quota, set aggregate mode to spill-mode`.
152-
- Disk spill for the Sort, MergeJoin, and HashJoin operator is introduced in v4.0.0; disk spill for the HashAgg operator is introduced in v5.2.0.
153-
- When the SQL executions containing Sort, MergeJoin, or HashJoin cause OOM, TiDB triggers disk spill by default. When SQL executions containing HashAgg cause OOM, TiDB does not trigger disk spill by default. You can configure the system variable `tidb_executor_concurrency = 1` to trigger disk spill for HashAgg.
152+
- Disk spill for the Sort, MergeJoin, and HashJoin operators is introduced in v4.0.0; disk spill for the non-concurrent algorithm of the HashAgg operator is introduced in v5.2.0; disk spill for the concurrent algorithm of the HashAgg operator is introduced in v8.0.0.
153+
- When the SQL executions containing Sort, MergeJoin, HashJoin, or HashAgg cause OOM, TiDB triggers disk spill by default.
154154

155155
> **Note:**
156156
>
@@ -182,15 +182,7 @@ The following example uses a memory-consuming SQL statement to demonstrate the d
182182
ERROR 1105 (HY000): Out Of Memory Quota![conn_id=3]
183183
```
184184

185-
4. Configure the system variable `tidb_executor_concurrency` to 1. With this configuration, when out of memory, HashAgg automatically tries to trigger disk spill.
186-
187-
{{< copyable "sql" >}}
188-
189-
```sql
190-
SET tidb_executor_concurrency = 1;
191-
```
192-
193-
5. Execute the same SQL statement. You can find that this time, the statement is successfully executed and no error message is returned. From the following detailed execution plan, you can see that HashAgg has used 600 MB of hard disk space.
185+
4. Execute the same SQL statement. You can find that this time, the statement is successfully executed and no error message is returned. From the following detailed execution plan, you can see that HashAgg has used 600 MB of hard disk space.
194186

195187
{{< copyable "sql" >}}
196188

system-variables.md

+13
Original file line numberDiff line numberDiff line change
@@ -2010,6 +2010,19 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;
20102010
- Default value: `OFF`
20112011
- This variable controls whether to enable TiDB to collect `PREDICATE COLUMNS`. After enabling the collection, if you disable it, the information of previously collected `PREDICATE COLUMNS` is cleared. For details, see [Collect statistics on some columns](/statistics.md#collect-statistics-on-some-columns).
20122012

2013+
### tidb_enable_concurrent_hashagg_spill <span class="version-mark">New in v8.0.0</span>
2014+
2015+
> **Warning:**
2016+
>
2017+
> Currently, the feature controlled by this variable is experimental. It is not recommended that you use it in production environments. If you find a bug, you can report an [issue](https://github.com/pingcap/tidb/issues) on GitHub.
2018+
2019+
- Scope: SESSION | GLOBAL
2020+
- Persists to cluster: Yes
2021+
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
2022+
- Type: Boolean
2023+
- Default value: `ON`
2024+
- This variable controls whether TiDB supports disk spill for the concurrent HashAgg algorithm. When it is `ON`, disk spill can be triggered for the concurrent HashAgg algorithm. This variable will be deprecated when this feature is generally available in a future release.
2025+
20132026
### tidb_enable_enhanced_security
20142027

20152028
- Scope: NONE

0 commit comments

Comments
 (0)