Help Center/ Data Warehouse Service/ Troubleshooting/ Cluster Performance/ Execution of SQL Statements Is Slow Due to Nested Loops in Execution Plans
Updated on 2025-04-10 GMT+08:00
Execution of SQL Statements Is Slow Due to Nested Loops in Execution Plans
Symptom
In a service environment, the performance of SQL queries is slow, and a Nested Loop Join is observed within the generated execution plan.
Cause Analysis
- Run the EXPLAIN VERBOSE command to print the statement execution plan. As shown in the following figure, the SQL statement contains the NOT IN statement.

- Check whether there are nested loops in the execution plan.

Analysis Results
- Nested loop is the main cause of slow statement execution.
- The NOT IN clause processes NULL values, which can lead to inefficient processing of statements through HashJoin, resulting in suboptimal performance.
Handling Procedure
- In scenarios where the handling of NULL values is not a concern for users, or if NULL values are absent in the data, substituting NOT IN with NOT EXISTS can be an effective optimization strategy.

Parent topic: Cluster Performance
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.