子选择是否比左外连接花费更多时间?
这取决于子选择和左外连接。
通常,此构造:
SELECT *
FROM mytable
WHERE mycol NOT IN
(
SELECT othercol
FROM othertable
)
比这更有效:
SELECT m.*
FROM mytable m
LEFT JOIN
othertable o
ON o.othercol = m.mycol
WHERE o.othercol IS NULL
看这里:
是否存在推荐不使用子选择的任何博客、文章或任何内容?
我会避开盲目推荐避免子选择的博客。
它们的实现是有原因的,不管你信不信,开发人员已经付出了一些努力来优化它们。
How I can prove that if we avoid subselesct in query that query is going to be faster ?
Write a query without the subselects which runs faster.
If you post your query here we possibly will be able to improve it. However, a version with the subselects may turn out to be faster.