Which SQL query is faster? Filter on Join criteria or Where clause?

前端 未结 9 983
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 03:36

Compare these 2 queries. Is it faster to put the filter on the join criteria or in the WHERE clause. I have always felt that it is faster on the join criteria b

9条回答
  •  感情败类
    2020-11-27 03:57

    For inner joins it doesn't matter where you put your criteria. The SQL compiler will transform both into an execution plan in which the filtering occurs below the join (ie. as if the filter expressions appears is in the join condition).

    Outer joins are a different matter, since the place of the filter changes the semantics of the query.

提交回复
热议问题