Priority scheduling can be based on CPU or I/O usage. The former puts new tasks in a resource pool based on the priority of associated cgroups, and the latter suspends I/O requests in the database. This section mainly describes CPU priority scheduling.
Resource load management has been enabled.
After the number of concurrent tasks of a resource pool reaches the upper limit, new tasks enter the waiting queue of the resource pool.
Queue in load management shows the queue mechanism for executing waiting tasks when resource load management is enabled.
Users' tasks enter queues of CNs, queues of resource pools, and then resource pools for execution. The process is described as follows:
If the resource proportion of a resource pool changes, change the priority of the resource pool accordingly. You can change the priority by modifying attributes in the resource pool.
ALTER RESOURCE POOL respool2 WITH(CONTROL_GROUP = "Rush"); ALTER RESOURCE POOL
The preceding statement changes the attribute of the cgroup associated with a resource pool to Rush.
ALTER USER user1 WITH RESOURCE POOL 'respool2'; ALTER ROLE
Where user1 is the user whose priority is to be changed, and respool2 is the resource pool it is to be bound to. You need the sysadmin permission to change the priority.
You can change the cgroup bound with the current session to adjust the priorities of the tasks in the session. For example:
SET CGROUP_NAME="Rush"; SET
View the cgroup bound to the current session.
If the priority of a task must be increased or a task must be executed at an earlier time, an administrator can change the position of the task in the queue.
SELECT * FROM pg_stat_activity where state = 'pending';
SELECT gs_wlm_switch_cgroup(threadid, 'High');
Only the administrator can adjust the priorities of tasks being executed.