Development is ongoing, so no optimization tip is reliable for the long term. 开发正在进行中,因此没有任何优化提示是长期可靠的。The following list provides some interesting tricks that you might want to play with. 下面的列表提供了一些您可能想玩的有趣技巧。See also Section 8.2.2, “Optimizing Subqueries, Derived Tables, View References, and Common Table Expressions”.另请参阅第8.2.2节,“优化子查询、派生表、视图引用和公共表表达式”。
Move clauses from outside to inside the subquery. 将子句从子查询的外部移到内部。For example, use this query:例如,使用以下查询:
SELECT * FROM t1 WHERE s1 IN (SELECT s1 FROM t1 UNION ALL SELECT s1 FROM t2);
Instead of this query:代替此查询:
SELECT * FROM t1 WHERE s1 IN (SELECT s1 FROM t1) OR s1 IN (SELECT s1 FROM t2);
For another example, use this query:例如,使用以下查询:
SELECT (SELECT column1 + 5 FROM t1) FROM t2;
Instead of this query:代替此查询:
SELECT (SELECT column1 FROM t1) + 5 FROM t2;