Changes the limits of a resource group, or renames it.
Synopsis
ALTER RESOURCE GROUP <name> SET <group_attribute> <value>where group_attribute is one of:
[ CONCURRENCY=<integer> ]
CPU_MAX_PERCENT=<integer> | CPUSET=<coordinator_cores>;<segment_cores>
[ CPU_WEIGHT=<integer> ]
[ MEMORY_QUOTA=<integer> ]
[ MIN_COST=<integer> ]
[ IO_LIMIT=' <tablespace_io_limit_spec> [; ...] ' ]
[ NAME <new_name> ]Where <tablespace_io_limit_spec> is:
<tablespace_name> | <oid> : <io_limit_option_spec> [, ...]Where <io_limit_option_spec> is:
wbps=<io_limit_option_value>
| rbps=<io_limit_option_value>
| wiops=<io_limit_option_value>
| riops=<io_limit_option_value>Where <io_limit_option_vlaue> is:
<integer> | maxDescription
ALTER RESOURCE GROUP changes the limits of a resource group. Only a superuser can alter a resource group.
You can set or reset the concurrency limit of a resource group that you create for roles to control the maximum number of active concurrent statements in that group. You can also reset the memory or CPU resources of a resource group to control the amount of memory or CPU resources that all queries submitted through the group can consume on each segment host.
When you alter the CPU resource management mode or limit of a resource group, the new mode or limit is immediately applied.
When you alter a memory quota of a resource group that you create for roles, the new resource limit is immediately applied if current resource usage is less than or equal to the new value and there are no running transactions in the resource group. If the current resource usage exceeds the new memory quota value, or if there are running transactions in other resource groups that hold some of the resource, then WarehousePG defers assigning the new limit until resource usage falls within the range of the new value.
When you increase the memory quota of a resource group that you create for external components, the new resource limit is phased in as system memory resources become available. If you decrease the memory quota of a resource group that you create for external components, the behavior is component-specific.
You can alter one limit type in a single ALTER RESOURCE GROUP call.
Parameters
nameThe name of the resource group to alter.
CONCURRENCYintegerThe maximum number of concurrent transactions, including active and idle transactions, that are permitted for this resource group. The
CONCURRENCYvalue must be an integer in the range [0 ..max_connections]. The defaultCONCURRENCYvalue for resource groups defined for roles is 20.You must set
CONCURRENCYto0for resource groups that you create for external components.Note You cannot set the
CONCURRENCYvalue for theadmin_groupto0.CPU_MAX_PERCENTintegerThe percentage of the maximum available CPU resources that the resource group can use. The value range is
1-100.CPU_WEIGHTintegerThe scheduling priority of the current group. The value range is
1-500, the default is100.CPUSET<coordinator_cores>;<segment_cores>Identifies the CPU cores to reserve for this resource group on the coordinator host and on segment hosts. The CPU cores that you specify must be available in the system and cannot overlap with any CPU cores that you specify for other resource groups.
Note You must specify either
CPU_MAX_PERCENTorCPUSETwhen you create a resource group, but not both.Specify cores as a comma-separated list of single core numbers or core number intervals. Define the coordinator host cores first, followed by segment host cores, and separate the two with a semicolon. You must enclose the full core configuration in single quotes. For example,
'1;1,3-4'configures core 1 for the coordinator host, and cores 1, 3, and 4 for the segment hosts.Note You can configure
CPUSETfor a resource group only after you have enabled resource group-based resource management for your WarehousePG cluster.IO_LIMIT'<tablespace_io_limit_spec> [; ...]'Optional. The maximum read/write sequential disk I/O throughput, and the maximum read/write I/O operations per second for the queries assigned to a specific resource group.
Where
<tablespace_io_limit_spec>is:<tablespace_name> | <oid> : <io_limit_option_spec> [, ...]Where
<io_limit_option_spec>is:wbps=<io_limit_option_value> | rbps=<io_limit_option_value> | wiops=<io_limit_option_value> | riops=<io_limit_option_value>Where
<io_limit_option_value>is:<integer> | maxWhen you use this parameter, specify:
- The tablespace name or the tablespace object ID (OID) you set the limits for. Use
*to set limits for all tablespaces. - The values for
rbpsandwbpsto limit the maximum read and write sequential disk I/O throughput in the resource group, in MB/S. The default value ismax, which means there is no limit. - The values for
riopsandwiopsto limit the maximum read and write I/O operations per second in the resource group. The default value ismax, which means there is no limit.
If
IO_LIMITis not set, the default value forrbps,wbps,riops, andwiopsismax, which means there are no disk I/O limits. In this scenario, thegp_toolkit.gp_resgroup_configsystem view displays its value as-1.Note The parameter
IO_LIMITis only available when you use Linux Control Groups v2. See Configuring and Using Resource Groups for more information.- The tablespace name or the tablespace object ID (OID) you set the limits for. Use
MEMORY_QUOTAintegerThe maximum available memory, in MB, to reserve for this resource group. This value determines the total amount of memory that all worker processes within a resource group can consume on a segment host during query execution.
The minimum memory quantity you can specify for a resource group is
0. The default value is-1.When you specify a
MEMORY_QUOTAof-1,MEMORY_QUOTAtakes the value of thestatement_memserver configuration parameter.Note If the server configuration parameter
gp_resgroup_memory_query_fixed_memis set, its value overrides at the session level the value ofMEMORY_QUOTA.MIN_COSTintegerThe limit on the cost of the query plan generated by a query in this resource group. When the query plan cost of the query is less than this value, the query is unassigned from the resource group to which it belongs, allowing low-cost queries to execute without resource constraints.
The value range is
0-500. The default value is0, which means that the cost is not used to bypass the query.NAMEnew_nameThe new name for the resource group. The name must be unique among all resource groups. You can't rename the default resource groups
admin_group,default_group, andsystem_group, and you can't usenoneas a new name.
Notes
Use CREATE ROLE or ALTER ROLE to assign a specific resource group to a role (user).
You cannot submit an ALTER RESOURCE GROUP command in an explicit transaction or sub-transaction.
Examples
Change the active transaction limit for a resource group:
ALTER RESOURCE GROUP rgroup1 SET CONCURRENCY 13;Update the CPU limit for a resource group:
ALTER RESOURCE GROUP rgroup2 SET CPU_MAX_PERCENT 45;Update the memory quota for a resource group:
ALTER RESOURCE GROUP rgroup3 SET MEMORY_QUOTA 300;Reserve CPU core 1 for a resource group on the coordinator host and all segment hosts:
ALTER RESOURCE GROUP rgroup5 SET CPUSET '1;1';Set disk I/O limits for tablespaces tablespace1 and a tablespace with oid 1663:
ALTER RESOURCE GROUP admin_group SET IO_LIMIT 'tablespace1:wbps=2000,wiops=2000;1663:rbps=2024,riops=2024';Rename a resource group:
ALTER RESOURCE GROUP rgroup1 SET NAME rgroup1_renamed;Compatibility
The ALTER RESOURCE GROUP statement is a WarehousePG extension. This command does not exist in standard PostgreSQL.
See Also
CREATE RESOURCE GROUP, DROP RESOURCE GROUP, CREATE ROLE, ALTER ROLE
Parent topic: SQL Commands
