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

sql-statement: calibrate resource support workload #13709

Merged
merged 22 commits into from
Apr 23, 2023
Merged
Changes from 8 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
39 changes: 31 additions & 8 deletions sql-statements/sql-statement-calibrate-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,29 @@ summary: TiDB 数据库中 CALIBRATE RESOURCE 的使用概况。

# `CALIBRATE RESOURCE`

`CALIBRATE RESOURCE` 语句用于预估并输出当前集群的 [`Request Unit (RU)`](/tidb-resource-control.md#什么是-request-unit-ru) 的容量。
`CALIBRATE RESOURCE` 语句用于预估并输出当前集群的 [`Request Unit (RU)`](/tidb-resource-control.md#什么是-request-unit-ru) 的容量。提供两种预估方式:
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

- 方法一:对于当前集群的实际负载,支持在指定时间窗口范围内查看,时间窗口最小为 10 分钟,最大为 24 小时。
- 方法二:支持指定 WORKLOAD 查看 RU 容量,默认为 TPCC,目前支持以下选项:
- OLTP_READ_WRITE
- OLTP_READ_ONLY
- OLTP_WRITE_ONLY
- TPCC
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

> **注意:**
>
> 集群 RU 的容量会随集群的拓扑结构和各个组件软硬件配置的变化而变化,每个集群实际能消耗的 RU 还与实际的负载相关。方法二的预估值仅供参考,可能会与实际的最大值存在偏差,建议采用方法一通过实际负载来进行预估。
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

## 语法图

```ebnf+diagram
CalibrateResourceStmt ::= 'CALIBRATE' 'RESOURCE'
```
CalibrateResourceStmt ::= 'CALIBRATE' 'RESOURCE' CalibrateOption

CalibrateOption ::=
('START_TIME' 'TIMESTAMP' ('DURATION' stringLit | 'END_TIME' 'TIMESTAMP')?)
| ('WORKLOAD' ('TPCC' | 'OLTP_READ_WRITE' | 'OLTP_READ_ONLY' | 'OLTP_WRITE_ONLY'))?

```
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

## 示例

Expand All @@ -20,11 +36,18 @@ CALIBRATE RESOURCE;
+-------+
| QUOTA |
+-------+
| 68569 |
| 190470 |
+-------+
1 row in set (0.03 sec)
1 row in set (0.01 sec)

```

> **注意:**
>
> 集群 RU 的容量会随集群的拓扑结构和各个组件软硬件配置的变化而变化,每个集群实际能消耗的 RU 还与实际的负载相关。此预估值仅供参考,可能会与实际的最大值存在偏差。
```sql
CALIBRATE RESOURCE WORKLOAD OLTP_READ_WRITE;
+-------+
| QUOTA |
+-------+
| 70702 |
+-------+
1 row in set (0.01 sec)
```