CREATE RESOURCE GROUP
You can use the CREATE RESOURCE GROUP
statement to create a resource group.
Synopsis
- CreateResourceGroupStmt
- IfNotExists
- ResourceGroupName
- ResourceGroupOptionList
- DirectResourceGroupOption
- ResourceGroupPriorityOption
CreateResourceGroupStmt ::=
"CREATE" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList
IfNotExists ::=
('IF' 'NOT' 'EXISTS')?
ResourceGroupName ::=
Identifier
ResourceGroupOptionList ::=
DirectResourceGroupOption
| ResourceGroupOptionList DirectResourceGroupOption
| ResourceGroupOptionList ',' DirectResourceGroupOption
DirectResourceGroupOption ::=
"RU_PER_SEC" EqOpt stringLit
| "PRIORITY" EqOpt ResourceGroupPriorityOption
| "BURSTABLE"
ResourceGroupPriorityOption ::=
LOW
| MEDIUM
| HIGH
The resource group name parameter (ResourceGroupName
) must be globally unique.
TiDB supports the following DirectResourceGroupOption
, where Request Unit (RU) is a unified abstraction unit in TiDB for CPU, IO, and other system resources.
Option | Description | Example |
---|---|---|
RU_PER_SEC | Rate of RU backfilling per second | RU_PER_SEC = 500 indicates that this resource group is backfilled with 500 RUs per second |
PRIORITY | The absolute priority of tasks to be processed on TiKV | PRIORITY = HIGH indicates that the priority is high. If not specified, the default value is MEDIUM . |
BURSTABLE | If the BURSTABLE attribute is set, TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. |
Examples
Create two resource groups rg1
and rg2
.
DROP RESOURCE GROUP IF EXISTS rg1;
Query OK, 0 rows affected (0.22 sec)
CREATE RESOURCE GROUP IF NOT EXISTS rg1
RU_PER_SEC = 100
PRIORITY = HIGH
BURSTABLE;
Query OK, 0 rows affected (0.08 sec)
CREATE RESOURCE GROUP IF NOT EXISTS rg2
RU_PER_SEC = 200;
Query OK, 0 rows affected (0.08 sec)
SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAME = 'rg2';
+------+------------+----------+-----------+
| NAME | RU_PER_SEC | PRIORITY | BURSTABLE |
+------+------------+----------+-----------+
| rg1 | 100 | HIGH | YES |
| rg2 | 200 | MEDIUM | NO |
+------+------------+----------+-----------+
2 rows in set (1.30 sec)
MySQL compatibility
MySQL also supports CREATE RESOURCE GROUP. However, the acceptable parameters are different from that of TiDB so that they are not compatible.
See also
Was this page helpful?