RESOURCE_GROUPS

RESOURCE_GROUPS 表展示所有资源组 (resource group) 的信息,见使用资源管控 (Resource Control) 实现资源隔离

USE information_schema; DESC resource_groups;
+------------+-------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+------+---------+-------+ | NAME | varchar(32) | NO | | NULL | | | RU_PER_SEC | bigint(21) | YES | | NULL | | | PRIORITY | varchar(6) | YES | | NULL | | | BURSTABLE | varchar(3) | YES | | NULL | | +------------+-------------+------+------+---------+-------+ 3 rows in set (0.00 sec)

示例

SELECT * FROM information_schema.resource_groups; -- 查看资源组,TiDB 默认预置 `default` 资源组
+---------+------------+----------+-----------+ | NAME | RU_PER_SEC | PRIORITY | BURSTABLE | +---------+------------+----------+-----------+ | default | UNLIMITED | MEDIUM | YES | +---------+------------+----------+-----------+
CREATE RESOURCE GROUP rg1 RU_PER_SEC=1000; -- 创建资源组 `rg1`
Query OK, 0 rows affected (0.34 sec)
SHOW CREATE RESOURCE GROUP rg1; -- 显示 `rg1` 资源组的定义
+----------------+---------------------------------------------------------------+ | Resource_Group | Create Resource Group | +----------------+---------------------------------------------------------------+ | rg1 | CREATE RESOURCE GROUP `rg1` RU_PER_SEC=1000 PRIORITY="MEDIUM" | +----------------+---------------------------------------------------------------+ 1 row in set (0.00 sec)
SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; -- 查看资源组 `rg1`
+------+------------+----------+-----------+-------------+ | NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | +------+------------+----------+-----------+-------------+ | rg1 | 1000 | MEDIUM | NO | NULL | +------+------------+----------+-----------+-------------+ 1 row in set (0.00 sec)

RESOURCE_GROUPS 表中列的含义如下:

  • NAME:资源组名称。
  • RU_PER_SEC:资源组的回填速度,单位为每秒回填的 Request Unit (RU) 数量。
  • PRIORITY:任务在 TiKV 上处理的绝对优先级。不同的资源按照 PRIORITY 的设置进行调度,PRIORITY 高的任务会被优先调度。如果资源组的 PRIORITY 相同,则会根据 RU_PER_SEC 的配置按比例调度。如果不指定 PRIORITY,资源组的默认优先级为 MEDIUM
  • BURSTABLE:是否允许此资源组超额使用剩余的系统资源。