All Products
Search
Document Center

PolarDB:DOP policies

Last Updated:Dec 15, 2024

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.

Note

The MySQL configuration file compatibility prefix loose_ is added to all cluster parameters in the PolarDB console. If you want to modify the parameters in the PolarDB console, make sure to modify the ones that contain the loose_ prefix.

Parameters that define the queuing policies of parallel queries

Parameter

Description

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 query is immediately removed from the queue and uses sequential execution instead.

Details of the DOP parameters

Parameter

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.

  • Valid values: 1 to 10000.

  • The default value is twice the number of CPU cores.

Note

The value of max_parallel_workers in a serverless cluster is adjusted based on the scaling of node specifications.

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.

  • Valid values: 0 to 10000.

  • Default value: 64.

pq_max_queuing_time

Global and session

The maximum waiting time in the queue. If the waiting time in the queue exceeds the specified value, sequential execution is used.

  • Valid values: 0 to 18446744073709551615.

  • Default value: 200.

  • 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:

  • TYPICAL: PolarDB sets the DOP to the same value as max_parallel_degree, regardless of database loads such as CPU utilization.

  • AUTO: PolarDB enables or disables the elastic parallel query feature based on database loads such as CPU utilization, and selects the DOP based on the query cost.

  • REPLICA_AUTO (default): Only read-only nodes determine whether to enable the elastic parallel query feature based on database loads such as CPU utilization, and select the DOP based on the query cost. The primary node does not perform elastic parallel query.

DOP control based on system resource usage

If parallel_degree_policy is set to AUTO or REPLICA_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. When parallel queries are enabled, you can set the DOP based on the system resource usage of parallel queries.

Parameter

Level

Description

auto_dop_cpu_pct_hwm

Global

The threshold of the CPU usage. If the CPU usage exceeds the threshold, PolarDB disables parallel queries.

  • Valid values: 0 to 100.

  • Default value: 70.

auto_dop_mem_pct_hwm

The threshold of the memory usage. If the memory usage exceeds the threshold, PolarDB disables parallel queries.

  • Valid values: 0 to 100.

  • Default value: 90.

auto_dop_iops_pct_hwm

The threshold of the IOPS usage. If the IOPS usage exceeds the threshold, PolarDB disables parallel queries.

  • Value values: 0 to 100.

  • Default value: 80.