PolarDB supports multiple policies to control the degree of parallelism (DOP) globally or for a single query and ensure that a reasonable DOP value is selected when resource loads are appropriate.
Parameters for parallel query queuing policies
max_parallel_workers specifies the maximum number of parallel workers within a single node. If the number of parallel workers exceeds the max_parallel_workers value, new parallel queries enters the queue and waits. The queue scheduling use the first-in, first-out (FIFO) policy.
queuing_parallel_degree_limit specifies the maximum DOP allowed in the queue. If the total number of parallel workers in the queue exceeds the queuing_parallel_degree_limit value, the queue is considered full and sequential execution is used for subsequent queries.
pq_max_queuing_time specifies the maximum waiting time in the queue. If the waiting time in the queue exceeds the specified value, the queue is immediately removed and sequential execution is used.
Parameters
Parameters | Level | Description |
max_parallel_workers | Global | The maximum number of parallel workers. If the number of parallel workers exceeds the specified value, new parallel queries enters the queue and waits.
|
queuing_parallel_degree_limit | Global | The maximum sum of DOP values for parallel queries that can enter the queue at a time. If the specified value is exceeded, parallel queries are prohibited and sequential execution is used.
|
pq_max_queuing_time | Global,Session | The maximum waiting time in the queue. If the waiting time in the queue exceeds the specified value, sequential execution is used. Unit: millisecond.
|
Statistical variables:
Variable | Level | Description |
PQ_refused_over_total_workers | Global and session | The number of queries that are not performed in parallel due to the limit on the total number of workers. |
PQ_refused_over_max_queuing_time | Global and session | The number of queries for which elastic parallel query fails due to queuing timeout. |
Total_running_parallel_workers | Global | The number of parallel workers that are running. |
Adaptive DOP settings
PolarDB supports adaptive DOP settings based on query costs and current resource loads, including DOP for single-node elastic parallel query and scheduling policies for multi-node elastic parallel query. The following table describes the parameters.
Parameter | Level | Description |
parallel_degree_policy | Global | The DOP policy for an individual query. Valid values:
|
parallel_workers_policy | session | The elastic parallel query policy. Valid values:
|
Limits on system resources
If the parallel_degree_policy parameter is set to AUTO, PolarDB enables or disables parallel queries based on the CPU usage, memory usage, or the input/output operations per second (IOPS) value of the database. PolarDB also sets the DOP based on the costs of parallel queries.
Parameter | Level | Value | Description |
loose_auto_dop_cpu_pct_hwm | Global |
| The threshold of the CPU usage. If the CPU usage exceeds the threshold, PolarDB disables parallel queries. |
loose_auto_dop_mem_pct_hwm |
| The threshold of the memory usage. If the memory usage exceeds the threshold, PolarDB disables parallel queries. | |
loose_auto_dop_iops_pct_hwm |
| The threshold of the IOPS usage. If the IOPS usage exceeds the threshold, PolarDB disables parallel queries. | |
loose_auto_dop_low_degree_cost |
| The policy that is used to automatically set the DOP. After you enable parallel queries, PolarDB sets the DOP based on the following rules:
Note This parameter is used to set the DOP only after PolarDB enables parallel queries. It is not used to enable or disable parallel queries. |