Subquery
- [Rule] Do not use repeated subquery statements in an SQL statement.
- [Recommendation] Do not use scalar subqueries.
A scalar subquery is a subquery whose result is one value and whose condition expression uses an equal operator. Example:
The following statement does not meet specifications:
SELECT * FROM t1 WHERE id = (SELECT id FROM t2 LIMIT 1);
You are advised to split the preceding statement into two SQL statements and execute the subquery first.
- [Recommendation] Do not use subqueries in the SELECT target columns. Otherwise, the plan cannot be pushed down, affecting the execution performance.
- [Recommendation] The nesting depth of a subquery cannot exceed 2.
Subqueries cause temporary table overhead. Therefore, complex queries must be optimized based on service logic.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot