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

resource_control: RU info in explain analyze #14234

Merged
merged 10 commits into from
Aug 3, 2023
12 changes: 12 additions & 0 deletions sql-statements/sql-statement-explain-analyze.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,18 @@ commit_txn: {prewrite:48.564544ms, wait_prewrite_binlog:47.821579, get_commit_ts
- `write_keys`: The total `keys` written in the transaction.
- `write_byte`: The total bytes of `key-value` written in the transaction, and the unit is byte.

### RU (Request Unit) Consumption
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

[Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) a unified abstraction unit of system resources which is defined in TiDB resource control. The `execution info` of top level operator shows the overall RU consumption of this particular SQL statement.
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

```
RU:273.842670
```

> **Notice :**
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
>
> This value shows the actual RU produced by this call. The RU consumption could vary if the same SQL statement repeats, as the amount of RU is affected by cache layer (for example, [coprocessor cache](/coprocessor-cache.md)).
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

### Other common execution information

The Coprocessor operators usually contain two parts of execution time information: `cop_task` and `tikv_task`. `cop_task` is the time recorded by TiDB, and it is from the moment that the request is sent to the server to the moment that the response is received. `tikv_task` is the time recorded by TiKV Coprocessor itself. If there is much difference between the two, it might indicate that the time spent waiting for the response is too long, or the time spent on gRPC or network is too long.
Expand Down
4 changes: 4 additions & 0 deletions tidb-resource-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Request Unit (RU) is a unified abstraction unit in TiDB for system resources, wh
> - In addition to queries executed by users, RU can be consumed by background tasks, such as automatic statistics collection.
> - The preceding table lists only the resources involved in RU calculation for TiDB Self-Hosted clusters, excluding the network and storage consumption. For TiDB Serverless RUs, see [TiDB Serverless Pricing Details](https://www.pingcap.com/tidb-cloud-serverless-pricing-details/).

### Predict RU consumption of SQL statements
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

[`explain analyze`](/sql-statements/sql-statement-explain-analyze.md#ru-request-unit-consumption) shows the actual RU produced by one particular SQL statement. Please be aware the RU consumption could vary if the same SQL statement repeats, as the amount of RU is affected by cache layer (for example, [coprocessor cache](/coprocessor-cache.md)). Even though this value doesn't reflect the exact RU produced by each execution, we can still come with an estimation based on this value.
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

## Parameters for resource control

The resource control feature introduces two new global variables.
Expand Down