Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explaination about tidb_allow_batch_cop #3002

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tidb-specific-system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,3 +571,13 @@ set tidb_query_log_max_len = 20
- Scope: SESSION
- Default value: 0
- This variable is used to show whether the execution plan used in the previous `execute` statement is taken directly from the plan cache.

Copy link
Contributor Author

@yikeke yikeke Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

- Scope: SESSION | GLOBAL
- Default value: 0
- This variable is used to control how TiDB sends a coprocessor request to TiFlash. It has the following values:

* `0`: Never send requests in batches
* `1`: Aggregation and join requests are sent in batches
* `2`: All coprocessor requests are sent in batches
26 changes: 25 additions & 1 deletion tiflash/tune-tiflash-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,34 @@ If you want to save machine resources and have no requirement on isolation, you
set @@tidb_distsql_scan_concurrency = 80;
```

2. Enable the optimization for TiDB Operator such as the aggregate pushdown of `JOIN` or `UNION`:
2. Enable the super batch feature:

You can use the [`tidb_allow_batch_cop`](/tidb-specific-system-variables.md#tidb_allow_batch_cop) variable to set whether to merge Region requests when reading from TiFlash.

When the number of Regions involved in the query is relatively large, try to set this variable to `1` (effective for coprocessor requests with `aggregation` operators that are pushed down to TiFlash), or set this variable to `2` (effective for all coprocessor requests that are pushed down to TiFlash).

{{< copyable "sql" >}}

```sql
set @@tidb_allow_batch_cop = 1;
```

3. Enable the optimization of pushing down aggregate functions before TiDB operators such as `JOIN` or `UNION`:

You can use the [`tidb_opt_agg_push_down`](/tidb-specific-system-variables.md#tidb_opt_agg_push_down) variable to control the optimizer to execute this optimization. When the aggregate operations are quite slow in the query, try to set this variable to `1`.

{{< copyable "sql" >}}

```sql
set @@tidb_opt_agg_push_down = 1;
```

4. Enable the optimization of pushing down aggregate functions with `Distinct` before TiDB operators such as `JOIN` or `UNION`:

You can use the [`tidb_opt_distinct_agg_push_down`](/tidb-specific-system-variables.md#tidb_opt_distinct_agg_push_down) variable to control the optimizer to execute this optimization. When the aggregate operations with `Distinct` are quite slow in the query, try to set this variable to `1`.

{{< copyable "sql" >}}

```sql
set @@tidb_opt_distinct_agg_push_down = 1;
```