SMP Parallel Execution

Complex queries may take a long time. In a system with low concurrency support, this can be a problem. SMP is used to implement operator-level parallel execution, which can effectively speed up queries, improving query performance and resource utilization.

The SMP feature improves performance through operator parallelism but may drive more resource usage, including CPU, memory, network, and I/O. In essence, SMP is a method that trades resources for time, meaning it accelerates queries at the cost of additional resources. It improves system performance in appropriate scenarios and when resources are sufficient, but may also deteriorate performance if used inappropriately. Furthermore, compared with serial processing, SMP generates more candidate plans, which is more time-consuming and may hurt performance.

The SMP feature of GaussDB(DWS) is controlled by the GUC parameter query_dop. Users use this parameter to specify an appropriate degree of query parallelism.

Application Scenarios and Constraints for SMP

Applicable Scenarios

Non-Applicable Scenarios

  1. Small queries are performed, where plan generation may account for a significant portion of the total query time.
  2. Operators are processed on CNs.
  3. Statements that cannot be pushed down are executed.
  4. The subplan of a query and operators containing a subquery are executed.

Impact of Resource Availability on SMP Performance

The SMP architecture accelerates queries at the cost of additional resources. After the plan parallelism is executed, more resources are consumed, including the CPU, memory, I/O, and network bandwidth. As the DOP grows, the resource consumption also increases. If these resources become a bottleneck, SMP cannot improve performance. On the contrary, it may do exactly the opposite. Adaptive SMP is provided to dynamically select the optimal parallel degree for each query based on the resource usage and query requirements. The following information describes the situations that the SMP affects theses resources:

Other Factors Impacting SMP Performance

Besides the resource factor, other factors may also impact SMP performance, such as uneven data distribution across tables and the degree of system parallelism.

Suggestions for SMP Parameter Settings

To enable the SMP adaptation function, set query_dop to 0 and adjust the following parameters to obtain an optimal DOP selection:

SMP Configuration Procedure

The CPU, memory, I/O, and network bandwidth resources are sufficient. In essence, SMP is a method that trades resources for time. After the plan parallelism is executed, resource consumption increases. When these resources become a bottleneck, SMP may deteriorate, rather than improve performance. In addition, it takes a longer time to generate SMP plans than serial plans. Therefore, in TP services that mainly involve short queries or in case resources are insufficient, you are advised to disable SMP by setting query_dop to 1.

Procedure:

  1. Observe the current system load situation. If the resource is sufficient (the resource usage ratio is smaller than 50%), perform step 2. Otherwise, exit this system.
  2. Set query_dop to 1 (default value). Use explain to generate an execution plan and check whether the plan can be used in scenarios described in Application Scenarios and Constraints for SMP. If the plan can be used, go to the next step.
  3. Set query_dop=–value. The value range of the parallelism degree is [1, value].
  4. Set query_dop=value. The parallelism degree is 1 or value.
  5. Before the query statement is executed, set query_dop to an appropriate value. After the statement is executed, set query_dop to off. For example:
    1
    2
    3
    4
    SET query_dop = 0;
    SELECT COUNT(*) FROM t1 GROUP BY a;
    ......
    SET query_dop = 1;
    
    • If resources are sufficient, the higher the degree of parallelism, the better the performance improvement result.
    • The SMP parallelism degree supports a session level setting and you are advised to enable SMP before executing queries that meet the requirements. After the execution is complete, disable SMP. Otherwise, SMP may affect services during peak hours.
    • SMP adaptability (query_dop ≤ 0) depends on resource management. If resource management is disabled, only plans with parallelism degree of only 1 or 2 will be generated.