CREATE RESOURCE POOL
Function
CREATE RESOURCE POOL creates a resource pool and specifies the Cgroup for the resource pool. The system resources (CPU, memory, I/O, and storage resources) of a database are limited. When multiple types of services (such as data loading, batch analysis, and real-time query) are running at the same time, they may compete for resources and hinder operations. As a result, the throughput decreases and the overall performance deteriorates. Allocating system resources correctly prevents efficiency loss due to poor resource use. DWS offers a resource management feature that lets you create separate resource pools for different needs. These pools keep resources independent from one another.
This syntax is for reference only. You are advised to create a resource pool on the console. For details about resource pools, see "DWS Resource Load Management" in the User Guide.
Precautions
As long as the current user has CREATE permission, it can create a resource pool.
Syntax
1 2 |
CREATE RESOURCE POOL pool_name [WITH ({MEM_PERCENT=pct | CONTROL_GROUP="group_name" | ACTIVE_STATEMENTS=stmt | MAX_DOP = dop | MEMORY_LIMIT='memory_size' | io_limits=io_limits | io_priority='priority' | nodegroup='nodegroup_name' | is_foreign = boolean | except_rule='except_rule' | weight=bandwidth_weight | enable_concurrency_scaling=boolean}[, ... ])]; |
Parameter Description
|
Parameter |
Description |
Value Range or Example |
||||
|---|---|---|---|---|---|---|
|
pool_name |
Specifies the name of a resource pool. The name of a resource pool cannot be same as that of an existing resource pool. |
A string, which must comply with the identifier naming convention. |
||||
|
CONTROL_GROUP |
Specifies the name of a Cgroup. Control groups (Cgroups) are a mechanism provided by the Linux kernel to restrict, record, and isolate physical resources (such as CPU, memory, and I/O resources) used by process groups. Cgroups have strict restrictions on Linux system resources. If a process is added to a Cgroup, it can use only restricted resources. For details about Cgroup principles, see the product manual corresponding to your OS. The DefaultClass Cgroup is preset in the environment, and the Timeshare Cgroup under the DefaultClass is divided into the following four levels: Rush, High, Medium, and Low.
|
Create a default resource pool, and associate it with the Medium Timeshare Workload Cgroup under DefaultClass.
Create a resource pool, and associate it with the High Timeshare Workload Cgroup under DefaultClass.
|
||||
|
ACTIVE_STATEMENTS |
Specifies the maximum number of complex statements that can be concurrently executed in a resource pool. The value is a number ranging from -1 to INT_MAX. If this parameter is not specified, the default value 10 is used. |
Create pool3 and set the maximum number of complex statements that can be concurrently executed to 5, the memory usage to 50%, and the network weight to 5.
|
||||
|
MAX_DOP |
Specifies the maximum number of simple SQL statements that can be concurrently executed in a resource pool. The value is a number ranging from -1 to INT_MAX. The value -1 or 0 indicates that the maximum number of statements is not limited. If the value is not specified, the default value -1 is used. |
Create pool4 and set the maximum number of concurrent simple SQL statements to 10.
|
||||
|
MEMORY_LIMIT |
Specifies the estimated maximum memory for a resource pool. A string.
If this parameter is not specified, default is used. |
- |
||||
|
MEM_PERCENT |
Specifies the proportion of available resource pool memory to the total memory or group user memory.
|
- |
||||
|
io_limits |
This parameter has been discarded in 8.1.2 and is reserved for compatibility with earlier versions. |
- |
||||
|
io_priority |
This parameter has been discarded in 8.1.2 and is reserved for compatibility with earlier versions. |
- |
||||
|
nodegroup |
Specifies the name of a logical cluster where the resource pool is. The logical cluster must already exist. |
If the logical cluster name contains uppercase letters or special characters or begins with a digit, enclose the name with double quotation marks in SQL statements. |
||||
|
is_foreign |
In logical cluster mode, the current resource pool is used to control the resources of common users who are not associated with the logical cluster specified by nodegroup. |
|
||||
|
except_rule |
Name of an exception rule set. An exception rule set is a set of rule thresholds that define the job execution time, job queuing time, CPU usage, and maximum disk flushing. It is used together with a resource pool. When an exception rule is triggered during job execution, the job is terminated or degraded. For more information, see CREATE EXCEPT RULE. |
Example: Create an exception rule to terminate a job when the job runs for more than 10 seconds. |
||||
|
weight |
Specifies the network bandwidth weight of the resource pool. The value is an integer ranging from -1 to 2147483647. The default value is -1, indicating that no weight is set. |
- |
||||
|
enable_concurrency_scaling |
Specifies whether to enable the elastic concurrency expansion function. This function is supported only by clusters of version 9.1.0.100 or later. |
The default value is false. |
Examples
This example assumes that Cgroups have been created by users in advance.
Create a default resource pool, and associate it with the Medium Timeshare Workload Cgroup under DefaultClass.
1
|
CREATE RESOURCE POOL pool1; |
Create a resource pool, and associate it with the High Timeshare Workload Cgroup under DefaultClass.
1
|
CREATE RESOURCE POOL pool2 WITH (CONTROL_GROUP="High"); |
Create pool_p and set the maximum number of complex statements that can be concurrently executed to 5, the memory usage to 50%, and the network weight to 5.
1
|
CREATE RESOURCE POOL pool_p WITH (ACTIVE_STATEMENTS=5, MEM_PERCENT=50, weight=5); |
Query the configuration parameters of the resource pool in the PG_RESOURCE_POOL system catalog.
1
|
SELECT * FROM PG_RESOURCE_POOL WHERE respool_name = 'pool_p'; |

1 2 |
CREATE EXCEPT RULE except_rule4 WITH (elapsedtime=10); CREATE resource pool resource_pool_a4 WITH (except_rule='except_rule4'); |
Create a resource pool and enable the elastic concurrent expansion function of the resource pool.
1
|
CREATE RESOURCE POOL pool6 WITH (enable_concurrency_scaling=true); |
Example: Create an exception rule to terminate a job when the job runs for more than 10 seconds.
In DWS resource load management, exception rules take effect only after being bound to a resource pool, and then the user who executes a job is bound to a specified resource pool. If an exception rule is triggered when a user executes a job, the job will be terminated. Perform the following operations to simulate the termination process.
- Create a test table and import data to the table.
- Connect to the database as the system administrator and run the following SQL statements to create temporary table src to provide data sources for subsequent INSERT operations:
1 2
CREATE SCHEMA test; CREATE TABLE test.src AS SELECT 1;
- Run the following SQL statements to create table test.test:
1 2
DROP TABLE IF EXISTS test.test; CREATE TABLE test.test(a int, b numeric(15,2)) WITH(orientation=column);
- Run the SQL statements to insert 20 million rows of data into the two tables. It takes about half a minute. Please wait.
1INSERT INTO test.test SELECT generate_series(1,20000000) % 1000,generate_series(1,20000000) FROM test.src;
- Connect to the database as the system administrator and run the following SQL statements to create temporary table src to provide data sources for subsequent INSERT operations:
- Create exception rule set except_rule4 and set elapsedtime to 10 seconds.
1CREATE EXCEPT RULE except_rule4 WITH (elapsedtime=10);
- Create resource pool resource_pool_a4 and bind the exception rule to it.
1CREATE resource pool resource_pool_a4 WITH (except_rule='except_rule4');
- Create a job user and bind the user to resource_pool_a4. The password is configured as required.
1CREATE USER user4 RESOURCE POOL 'resource_pool_a4' PASSWORD 'password';
- Grant the permission to access table test.test to user4.
1 2
GRANT USAGE ON SCHEMA test TO user4; GRANT SELECT ON TABLE test.test TO user4;
- Connect to the database as user4 and run the following SQL statement. Once the statement is executed for more than 10 seconds, it is terminated.
1SELECT * FROM test.test;

- Check exception rule definitions in the PG_EXCEPT_RULE system catalog.
1SELECT * FROM PG_EXCEPT_RULE WHERE name = 'except_rule4';

Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot