Performance of ON Clause over WHERE Clause
Can anyone please tell me Which of the following queries will have better performance?
SELECT
*
FROM
[TABLE1] T1
INNER JOIN [TABLE2] T2
ON T2.[FK_ID] = T1.[PK_ID]
WHERE
T2.[ACTIVE]开发者_JAVA技巧 = 1;
SELECT
*
FROM
[TABLE1] T1
INNER JOIN [TABLE2] T2
ON T2.[FK_ID] = T1.[PK_ID] AND
T2.[ACTIVE] = 1;
hpe this will give you answer : http://bytes.com/topic/sql-server/answers/850159-performance-conditions-where-clause-vs-conditions-inner-join
They are identical: the optimizer is clever enough to work this out.
Not least, SQL is declarative so you're asking the optimizer for something but not telling it how to do it.
However, the first one is "correct" in that you are separating JOIN and WHERE.
精彩评论