The SET_CONSUMER_GROUP_MAPPING procedure is used to add, modify, or drop the mapping of session and resource group based on the login and runtime session attributes. This enables finer-grained resource management.
Syntax
DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(
attribute IN VARCHAR2,
value IN VARCHAR2,
consumer_group IN VARCHAR2 DEFAULT NULL
);
Parameters
| Parameter | Description |
|---|---|
| attribute | Specifies the mapping attribute to be added or modified. Currently, only the USER, COLUMN, and FUNCTION attributes are supported. Since OceanBase Database's internal tasks such as minor compactions, major compactions, backups, data restore, and data recovery may consume CPU or I/O resources of other users or tasks, you can specify the FUNCTION attribute to map internal tasks to specified resource groups so that resource consumption of the tasks is limited to their resource groups. |
| value | Specifies the value of the attribute that must match the specified attribute. You can enter a literal or a regular expression. |
| consumer_group | Specifies the resource group to which to map the specified attribute value. If this parameter is NULL, the mapping is dropped. |
Considerations
- If no mapping is specified for the attribute and value, a mapping is created for the specified resource group.
- If a mapping is specified for the attribute and value, the resource group of the mapping is updated to the specified one.
- If
consumer_groupisNULL, all the mappings for the specified attribute and value are dropped.
The following table lists the built-in FUNCTION resource group mapping rules in OceanBase Database. You can use the DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING procedure to modify or drop these mapping rules.
- USER: All sessions of the specified user are mapped to the target resource group.
- COLUMN: You can map the value of a specific table field, for example,
t2.c3=3for user1, to a resource group. This way, you can achieve more granular resource isolation. - FUNCTION: You can map internal tasks such as major compactions, backups, and statistics collection to a resource group. The following table lists the built-in
FUNCTIONtypes.
| Attribute | Value | Description |
|---|---|---|
| FUNCTION | COMPACTION_HIGH | Mini Merge and DDL KV Merge tasks |
| FUNCTION | COMPACTION_MID | Minor Merge tasks |
| FUNCTION | COMPACTION_LOW | Major Merge tasks |
| FUNCTION | HA_HIGH | Replication, Rebuild, and data restore tasks |
| FUNCTION | HA_MID | Migration tasks |
| FUNCTION | HA_LOW | Backup and garbage collection of backup files |
| FUNCTION | DDL | Operations such as checking the uniqueness of columns, dropping columns, and completing data. |
| FUNCTION | DDL_HIGH | Dumping of DDL MemTables. |
| FUNCTION | CLOG_HIGH | CLog log submission tasks. |
| FUNCTION | OPT_STATS | Statistics collection tasks. |
| FUNCTION | MVIEW | I/O and CPU resource operations for incremental refreshes of materialized views and the purge of MLogs. |
Examples
1. Map by user
CALL DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(
attribute => 'USER',
value => 'user1',
consumer_group => 'group1'
);
2. Map by table field values
CALL DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(
attribute => 'COLUMN',
value => 't2.c3 = 3 for user1',
consumer_group => 'group1'
);
3. Map by internal task types
CALL DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(
attribute => 'FUNCTION',
value => 'COMPACTION_HIGH',
consumer_group => 'group2'
);
