开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜