Working with resource groups v15
Use these data definition language commands to create and manage resource groups.
Creating a resource group
Use the CREATE RESOURCE GROUP
command to create a new resource group.
CREATE RESOURCE GROUP <group_name>;
Description
The CREATE RESOURCE GROUP
command creates a resource group with the specified name. You can then define resource limits on the group with the ALTER RESOURCE GROUP
command. The resource group is accessible from all databases in the EDB Postgres Advanced Server instance.
To use the CREATE RESOURCE GROUP
command, you must have superuser privileges.
Parameters
group_name
The name of the resource group.
Example
This example creates three resource groups named resgrp_a
, resgrp_b
, and resgrp_c
:
edb=# CREATE RESOURCE GROUP resgrp_a; CREATE RESOURCE GROUP edb=# CREATE RESOURCE GROUP resgrp_b; CREATE RESOURCE GROUP edb=# CREATE RESOURCE GROUP resgrp_c; CREATE RESOURCE GROUP
This query shows the entries for the resource groups in the edb_resource_group
catalog:
edb=# SELECT * FROM edb_resource_group;
rgrpname | rgrpcpuratelimit | rgrpdirtyratelimit -----------+------------------+-------------------- resgrp_a | 0 | 0 resgrp_b | 0 | 0 resgrp_c | 0 | 0 (3 rows)
Modifying a resource group
Use the ALTER RESOURCE GROUP
command to change the attributes of an existing resource group. The command syntax comes in three forms.
This form renames the resource group:
ALTER RESOURCE GROUP <group_name> RENAME TO <new_name>;
This form assigns a resource type to the resource group:
ALTER RESOURCE GROUP <group_name> SET <resource_type> { TO | = } { <value> | DEFAULT };
This form resets the assignment of a resource type to its default in the group:
ALTER RESOURCE GROUP <group_name> RESET <resource_type>;
Description
The ALTER RESOURCE GROUP
command changes certain attributes of an existing resource group.
The form with the RENAME TO
clause assigns a new name to an existing resource group.
The form with the SET resource_type TO
clause assigns the specified literal value to a resource type. Or, when you specify DEFAULT
, it resets the resource type. Resetting a resource type means that the resource group has no defined limit on that resource type.
The form with the RESET resource_type
clause resets the resource type for the group.
To use the ALTER RESOURCE GROUP
command, you must have superuser privileges.
Parameters
group_name
The name of the resource group to alter.
new_name
The new name to assign to the resource group.
resource_type
Specifies the type of resource to which to set a usage value.
value | DEFAULT
When value
is specified, the literal value to assign to resource_type
. Specify DEFAULT
to reset the assignment of resource_type
for the resource group.
Example
These examples show the use of the ALTER RESOURCE GROUP
command:
edb=# ALTER RESOURCE GROUP resgrp_a RENAME TO newgrp; ALTER RESOURCE GROUP edb=# ALTER RESOURCE GROUP resgrp_b SET cpu_rate_limit = .5; ALTER RESOURCE GROUP edb=# ALTER RESOURCE GROUP resgrp_b SET dirty_rate_limit = 6144; ALTER RESOURCE GROUP edb=# ALTER RESOURCE GROUP resgrp_c RESET cpu_rate_limit; ALTER RESOURCE GROUP
This query shows the results of the ALTER RESOURCE GROUP
commands to the entries in the edb_resource_group
catalog:
edb=# SELECT * FROM edb_resource_group;
rgrpname | rgrpcpuratelimit | rgrpdirtyratelimit -----------+------------------+-------------------- newgrp | 0 | 0 resgrp_b | 0.5 | 6144 resgrp_c | 0 | 0 (3 rows)
Removing a resource group
Use the DROP RESOURCE GROUP
command to remove a resource group.