SET RESOURCE GROUP

April 22, 2026 ยท View on GitHub

SET RESOURCE GROUP is used to set the resource group for the current session.

Note:

This feature is not available on {{{ .starter }}} and {{{ .essential }}} instances.

Synopsis

SetResourceGroupStmt:

SetResourceGroupStmt ::=
    "SET" "RESOURCE" "GROUP" ResourceGroupName

ResourceGroupName ::=
    Identifier
|   "DEFAULT"

Privilege

Executing this statement requires the following configuration and privilege:

  1. The system variable tidb_enable_resource_control is set to ON.
  2. When the system variable tidb_resource_control_strict_mode is set to ON, you need to have the SUPER or RESOURCE_GROUP_ADMIN or RESOURCE_GROUP_USER privilege; when it is set to OFF, none of these privileges are required.

Examples

Create a user user1, create two resource groups rg1 and rg2, and bind the user user1 to the resource group rg1.

CREATE USER 'user1';
CREATE RESOURCE GROUP 'rg1' RU_PER_SEC = 1000;
ALTER USER 'user1' RESOURCE GROUP `rg1`;

Use user1 to log in and view the resource group bound to the current user.

SELECT CURRENT_RESOURCE_GROUP();
+--------------------------+
| CURRENT_RESOURCE_GROUP() |
+--------------------------+
| rg1                      |
+--------------------------+
1 row in set (0.00 sec)

Execute SET RESOURCE GROUP to set the resource group for the current session to rg2.

SET RESOURCE GROUP `rg2`;
SELECT CURRENT_RESOURCE_GROUP();
+--------------------------+
| CURRENT_RESOURCE_GROUP() |
+--------------------------+
| rg2                      |
+--------------------------+
1 row in set (0.00 sec)

Execute SET RESOURCE GROUP to specify the current session to use the default resource group.

SET RESOURCE GROUP `default`;
SELECT CURRENT_RESOURCE_GROUP();
+--------------------------+
| CURRENT_RESOURCE_GROUP() |
+--------------------------+
| default                  |
+--------------------------+
1 row in set (0.00 sec)

MySQL compatibility

MySQL also supports SET RESOURCE GROUP. But the accepted parameters are different from that of TiDB. They are not compatible.

See also