CREATE RESOURCE GROUP

Define a new resource group.

Summary

CREATE RESOURCE GROUP name WITH (group_attribute=value [, ... ])

Where group_attribute is:

CPU_RATE_LIMIT=integer | CPUSET=tuple
MEMORY_LIMIT=integer
[ CONCURRENCY=integer ]
[ MEMORY_SHARED_QUOTA=integer ]
[ MEMORY_SPILL_RATIO=integer ]
[ MEMORY_AUDITOR= {vmtracker | cgroup} ]

describe

Create a new resource group for YMatrix database resource management. You can create resource groups to manage role resources or to manage resources for external components of YMatrix databases, such as PL/Container.

When the resource group is enabled, the resource group you create to manage the user role will identify the concurrent transactions, memory, and CPU limits for that role. You can assign such resource groups to one or more roles.

The resource group you create that manages resources that are external to YMatrix databases, such as PL/Container, identifies the memory and CPU limits of the component when the resource group is enabled. These resource groups use cgroups for CPU and memory management. Assigning resource groups to external components is component-specific. For example, when you configure the PL/Container runtime, you will assign a PL/Container resource group. You cannot assign resource groups created for external components to roles, nor can you assign resource groups created for roles to external components.

You must have SUPERUSER privileges to create a resource group. The maximum number of resource groups allowed in a YMatrix database cluster is 100.

The YMatrix database predefined two default resource groups: admin_group and default_group. These group names and group names none are retained.

To set appropriate restrictions for resource groups, YMatrix database administrators must be familiar with the queries that are typically executed on the system, as well as the users/roles that execute these queries and the external components they may use, such as PL/Containers.

After creating a role for the resource group, the group is assigned to one or more roles using the ALTER ROLE or CREATE ROLE command.

After creating a resource group to manage CPU and memory resources for external components, configure the external components to use the resource group. For example, configure the resource_group_id of the PL/Container runtime.

Parameters

name

  • Name of the resource group.

CONCURRENCY integer

  • The maximum number of concurrent transactions allowed by this resource group, including active and idle transactions. The CONCURRENCY value must be an integer in the range [0.. max_connections]. The default CONCURRENCY value for resource groups defined for roles is 20.
    For resource groups created for external components, CONCURRENCY must be set to zero (0).
    Note: You cannot set the CONCURRENCY value of admin_group to zero (0).

CPU_RATE_LIMIT integer

CPUSET tuple

  • When creating a resource group, you can only specify one of CPU_RATE_LIMIT or CPUSET.
    CPU_RATE_LIMIT is the percentage of CPU resources allocated to the resource group. The minimum CPU percentage you can specify for the resource group is 1. Maximum is 100. The sum of CPU_RATE_LIMIT values ​​specified for all resource groups defined in the YMatrix database cluster must be less than or equal to 100.
    CPUSET identifies the CPU core to be reserved for this resource group. The CPU core you specify in the tuple must be available on the system and cannot overlap with any CPU cores you specify for other resource groups. Tuple is a comma-separated list of single core numbers or core numbers. You have to enclose the tuple in single quotes, for example '1,3-4'.

MEMORY_LIMIT integer

  • need. The total percentage of the YMatrix database memory resources assigned to this resource group. The minimum memory percentage you can specify for a resource group is 0 and a maximum of 100. When set to 0, YMatrix does not allocate any reserved memory for the group, but uses global shared memory. And MEMORY_SPILL_RATIO must also be set to 0.
    The sum of MEMORY_LIMIT defined by all resource groups in the YMatrix database cluster cannot exceed 100. When the sum is less than 100, the remaining part is global shared memory.

MEMORY_SHARED_QUOTA integer

  • Quota for shared memory in resource groups. The resource group with the MEMORY_SHARED_QUOTA threshold reserves the percentage of memory allocated to the resource group to share between transactions. Shared memory will be allocated on a first come first served basis. Transactions may not use any, part or all of the memory. The minimum memory sharing quota percentage you can specify for resource groups is 0. Maximum is 100. The default MEMORY_SHARED_QUOTA value is 20.

MEMORY_SPILL_RATIO integer

  • Memory usage threshold for memory-intensive operations in transactions. When this threshold is reached, the transaction overflows to disk. The minimum memory overflow percentage you can specify for resource groups is 0. The maximum value is 100. The default MEMORY_SPILL_RATIO value is 20.

MEMORY_AUDITOR {vmtracker | cgroup}

  • Memory auditor for resource groups. The YMatrix database uses virtual memory tracking for role resources and cgroup memory tracking for resources used by external components. The default MEMORY_AUDITOR is vmtracker. When creating a resource group using vmtracker memory audit, the YMatrix database internally tracks the memory of the resource group.
    When you create a resource group that specifies cgroup MEMORY_AUDITOR, the YMatrix database defers the memory accounting used by the resource group to the cgroup. For resource groups you create for external components such as PL/Container, CONCURRENCY must be zero (0). You cannot assign resource groups created for external components to the YMatrix database role.

Note

You cannot submit a CREATE RESOURCE GROUP command in an explicit transaction or a subtransaction.

Use the gp_toolkit.gp_resgroup_config system view to display the limit settings for all resource groups:

SELECT * FROM gp_toolkit.gp_resgroup_config;

Example

Create a resource group with a CPU and memory limit percentage of 35:

CREATE RESOURCE GROUP rgroup1 WITH (CPU_RATE_LIMIT=35, MEMORY_LIMIT=35);

Create a resource group with a concurrent transaction limit of 20, a memory limit of 15, and a CPU limit of 25:

CREATE RESOURCE GROUP rgroup2 WITH (CONCURRENCY=20, 
  MEMORY_LIMIT=15, CPU_RATE_LIMIT=25);

Create a resource group to manage PL/Container resources, specifying memory limits of 10 and CPU limits of 10:

CREATE RESOURCE GROUP plc_run1 WITH (MEMORY_LIMIT=10, CPU_RATE_LIMIT=10,
  CONCURRENCY=0, MEMORY_AUDITOR=cgroup);

Create a resource group with a memory limit percentage of 11 and assign it CPU cores 1 to 3:

CREATE RESOURCE GROUP rgroup3 WITH (CPUSET='1-3', MEMORY_LIMIT=11);

compatibility

CREATE RESOURCE GROUP is a YMatrix data extension. There is no resource group or resource management in the SQL standard.

See also

ALTER RESOURCE GROUP, DROP RESOURCE GROUP