Skip to content

Commit b781030

Browse files
committed
add translation
1 parent bbcbf92 commit b781030

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed

TOC.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@
789789
- [`DELETE`](/sql-statements/sql-statement-delete.md)
790790
- [`DESC`](/sql-statements/sql-statement-desc.md)
791791
- [`DESCRIBE`](/sql-statements/sql-statement-describe.md)
792+
- [`DISTRIBUTE TABLE`](/sql-statements/sql-statement-distribute-table.md)
792793
- [`DO`](/sql-statements/sql-statement-do.md)
793794
- [`DROP BINDING`](/sql-statements/sql-statement-drop-binding.md)
794795
- [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md)
@@ -853,6 +854,7 @@
853854
- [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md)
854855
- [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md)
855856
- [`SHOW DATABASES`](/sql-statements/sql-statement-show-databases.md)
857+
- [`SHOW DISTRIBUTION JOBS`](/sql-statements/sql-statement-show-distribution-jobs.md)
856858
- [`SHOW ENGINES`](/sql-statements/sql-statement-show-engines.md)
857859
- [`SHOW ERRORS`](/sql-statements/sql-statement-show-errors.md)
858860
- [`SHOW FIELDS FROM`](/sql-statements/sql-statement-show-fields-from.md)
@@ -875,6 +877,7 @@
875877
- [`SHOW STATS_META`](/sql-statements/sql-statement-show-stats-meta.md)
876878
- [`SHOW STATS_TOPN`](/sql-statements/sql-statement-show-stats-topn.md)
877879
- [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md)
880+
- [`SHOW TABLE DISTRIBUTION`](/sql-statements/sql-statement-show-table-distribution.md)
878881
- [`SHOW TABLE NEXT_ROW_ID`](/sql-statements/sql-statement-show-table-next-rowid.md)
879882
- [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md)
880883
- [`SHOW TABLE STATUS`](/sql-statements/sql-statement-show-table-status.md)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: DISTRIBUTE TABLE
3+
summary: An overview of the usage of DISTRIBUTE TABLE for the TiDB database.
4+
---
5+
6+
# DISTRIBUTE TABLE
7+
8+
The `DISTRIBUTE TABLE` statement redistributes and reschedules Regions of a specified table to achieve a balanced distribution at the table level. Executing this statement helps prevent Regions from being concentrated on a few TiFlash or TiKV nodes, addressing the issue of uneven region distribution in the table.
9+
10+
## Syntax
11+
12+
```ebnf+diagram
13+
DistributeTableStmt ::=
14+
"DISTRIBUTE" "TABLE" TableName PartitionNameList? EngineOption? RoleOption?
15+
16+
TableName ::=
17+
(SchemaName ".")? Identifier
18+
19+
PartitionNameList ::=
20+
"PARTITION" "(" PartitionName ("," PartitionName)* ")"
21+
22+
EngineOption ::=
23+
"ENGINE" Expression
24+
25+
RoleOption ::=
26+
"Role" Expression
27+
```
28+
29+
## Examples
30+
31+
When redistributing Regions using the `DISTRIBUTE TABLE` statement, you can specify the storage engine (such as TiFlash or TiKV) and different Raft roles (such as Leader, Learner, or Voter) for balanced distribution.
32+
33+
Redistribute the Regions of the Leader in the table `t1` on TiKV:
34+
35+
```sql
36+
CREATE TABLE t1 (a INT);
37+
...
38+
DISTRIBUTE TABLE t1 engine tikv role leader
39+
```
40+
41+
```
42+
+---------+
43+
| JOB_ID |
44+
100
45+
+---------+
46+
```
47+
48+
Redistribute the Regions of the Learner in the table `t2` on TiFlash:
49+
50+
```sql
51+
CREATE TABLE t2 (a INT);
52+
...
53+
DISTRIBUTE TABLE t2 ENGINE tiflash role learner;
54+
```
55+
56+
```
57+
+---------+
58+
| JOB_ID |
59+
101
60+
+---------+
61+
```
62+
63+
Redistribute the Regions of the Leader in the table `t3`'s `p1` and `p2` partitions on TiKV:
64+
65+
```sql
66+
CREATE TABLE t3 (a INT);
67+
...
68+
DISTRIBUTE TABLE t3 PARTITION (p1, p2) ENGINE tikv role leader;
69+
```
70+
71+
```
72+
+---------+
73+
| JOB_ID |
74+
102
75+
+---------+
76+
```
77+
78+
Execute the [`SHOW DISTRIBUTION JOBS`](/sql-statements/sql-statement-show-distribution-jobs.md) statement to view all distribution jobs:
79+
80+
```sql
81+
SHOW DISTRIBUTION JOBS;
82+
```
83+
84+
```
85+
+---------+------------+------------+-----------------+------------+-----------+----------+-------------+---------------+
86+
| JOB_ID | DB_NAME | TABLE_NAME | PARTITION_NAMES | ENGINE_TYPE | ROLE_TYPE | STATUS | CREATE_USER | CREATE_TIME |
87+
+---------+------------+------------+-----------------+------------+-----------+--------+---------------+---------------+
88+
| 1 | db_1 | t1 | | TIKV | LEADER | RUNNING | ADMIN | 20240712 |
89+
| 2 | db_1 | t2 | | TIFLASH | LEARNER | FINISHED | ADMIN | 20240715 |
90+
| 3 | db_1 | t3 | | TiKV | VOTER | STOPPED | ADMIN | 20240713 |
91+
| 4 | db_1 | t4 | | TIFLASH | LEARNER | FINISHED | ADMIN | 20240713 |
92+
+---------+------------+------------+-----------------+------------+-----------+----------+-------------+---------------+
93+
```
94+
95+
Execute the [`SHOW TABLE DISTRIBUTION`](/sql-statements/sql-statement-show-table-distribution.md) statement to view the Region distribution of the table `t1`:
96+
97+
```sql
98+
SHOW TABLE DISTRIBUTION t1;
99+
```
100+
101+
```
102+
+---------+------------+----------------+----------+------------+-------------------+--------------------+-----------------+------------------+
103+
| DB_NAME | TABLE_NAME | PARTITION_NAME | STORE_ID | STORE_TYPE | REGION_LEADER_NUM | REGION_LEADER_BYTE | REGION_PEER_NUM | REGION_PEER_BYTE |
104+
+---------+------------+----------------+----------+------------+-------------------+--------------------+-----------------+------------------+
105+
| db_1 | t1 | | 1 | TiKV | 315 | 24057934521 | 1087 | 86938746542 |
106+
| db_1 | t1 | | 2 | TiKV | 324 | 28204839240 | 1104 | 91039476832 |
107+
| db_1 | t1 | | 3 | TiKV | 319 | 25986274812 | 1091 | 89405367423 |
108+
| db_1 | t1 | | 4 | TiKV | 503 | 41039587625 | 1101 | 90482317797 |
109+
+---------+------------+----------------+----------+------------+-------------------+--------------------+-----------------+------------------+
110+
```
111+
112+
## Notes
113+
114+
When you execute the `DISTRIBUTE TABLE` statement to redistribute Regions of a table, the Region distribution result might be affected by the PD hotspot scheduler. After the redistribution, the Region distribution of this table might become imbalanced again over time.
115+
116+
## MySQL compatibility
117+
118+
This statement is a TiDB extension to MySQL syntax.
119+
120+
## See also
121+
122+
- [`SHOW DISTRIBUTION JOBS`](/sql-statements/sql-statement-show-distribution-jobs.md)
123+
- [`SHOW TABLE DISTRIBUTION`](/sql-statements/sql-statement-show-table-distribution.md)
124+
- [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: SHOW DISTRIBUTION JOBS
3+
summary: An overview of the usage of SHOW DISTRIBUTION JOBS for the TiDB database.
4+
---
5+
6+
# SHOW DISTRIBUTION JOBS
7+
8+
The `SHOW DISTRIBUTION JOBS` statement shows all current Region distribution jobs.
9+
10+
## Syntax
11+
12+
```ebnf+diagram
13+
ShowDistributionJobsStmt ::=
14+
"SHOW" "DISTRIBUTION" "JOBS"
15+
```
16+
17+
## Examples
18+
19+
Show all current Region distribution jobs:
20+
21+
```sql
22+
SHOW DISTRIBUTION JOBS;
23+
```
24+
25+
```
26+
+---------+------------+------------+-----------------+------------+-----------+----------+-------------+---------------+
27+
| JOB_ID | DB_NAME | TABLE_NAME | PARTITION_NAMES | ENGINE_TYPE | ROLE_TYPE | STATUS | CREATE_USER | CREATE_TIME |
28+
+---------+------------+------------+-----------------+------------+-----------+--------+---------------+---------------+
29+
| 1 | db_1 | t1 | | TIKV | LEADER | RUNNING | ADMIN | 20240712 |
30+
| 2 | db_1 | t2 | | TIFLASH | LEARNER | FINISHED | ADMIN | 20240715 |
31+
| 3 | db_1 | t3 | | TiKV | VOTER | STOPPED | ADMIN | 20240713 |
32+
| 4 | db_1 | t4 | | TIFLASH | LEARNER | FINISHED | ADMIN | 20240713 |
33+
+---------+------------+------------+-----------------+------------+-----------+----------+-------------+---------------+
34+
```
35+
36+
## MySQL compatibility
37+
38+
This statement is a TiDB extension to MySQL syntax.
39+
40+
## See Also
41+
42+
- [`DISTRIBUTE TABLE`](/sql-statements/sql-statement-distribute-table.md)
43+
- [`SHOW TABLE DISTRIBUTION`](/sql-statements/sql-statement-show-table-distribution.md)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: SHOW TABLE DISTRIBUTION
3+
summary: An overview of the usage of SHOW TABLE DISTRIBUTION for the TiDB database.
4+
---
5+
6+
# SHOW TABLE DISTRIBUTION
7+
8+
The `SHOW TABLE DISTRIBUTION` statement shows the Region distribution information for a specified table.
9+
10+
## Syntax
11+
12+
```ebnf+diagram
13+
ShowTableDistributionStmt ::=
14+
"SHOW" "TABLE" "DISTRIBUTION" TableName
15+
16+
TableName ::=
17+
(SchemaName ".")? Identifier
18+
```
19+
20+
## Examples
21+
22+
Show the Region distribution of the table `t1`:
23+
24+
```sql
25+
SHOW TABLE DISTRIBUTION t1;
26+
```
27+
28+
```
29+
+---------+------------+----------------+----------+------------+-------------------+--------------------+-----------------+------------------+
30+
| DB_NAME | TABLE_NAME | PARTITION_NAME | STORE_ID | STORE_TYPE | REGION_LEADER_NUM | REGION_LEADER_BYTE | REGION_PEER_NUM | REGION_PEER_BYTE |
31+
+---------+------------+----------------+----------+------------+-------------------+--------------------+-----------------+------------------+
32+
| db_1 | t1 | | 1 | TiKV | 315 | 24057934521 | 1087 | 86938746542 |
33+
| db_1 | t1 | | 2 | TiKV | 324 | 28204839240 | 1104 | 91039476832 |
34+
| db_1 | t1 | | 3 | TiKV | 319 | 25986274812 | 1091 | 89405367423 |
35+
| db_1 | t1 | | 4 | TiKV | 503 | 41039587625 | 1101 | 90482317797 |
36+
+---------+------------+----------------+----------+------------+-------------------+--------------------+-----------------+------------------+
37+
```
38+
39+
## MySQL compatibility
40+
41+
This statement is a TiDB extension to MySQL syntax.
42+
43+
## See Also
44+
45+
- [`DISTRIBUTE TABLE`](/sql-statements/sql-statement-distribute-table.md)
46+
- [`SHOW DISTRIBUTION JOBS`](/sql-statements/sql-statement-show-distribution-jobs.md)

0 commit comments

Comments
 (0)