WHERE clause better execute before IN and JOIN or after

前端 未结 5 1505
感动是毒
感动是毒 2020-11-30 02:12

I read this article: Logical Processing Order of the SELECT statement

in end of article has been write ON and JOIN clause consider before WHERE.

Consider we

5条回答
  •  半阙折子戏
    2020-11-30 02:50

    It doesn't matter

    Logical processing order is always honoured: regardless of actual processing order

    INNER JOINs and WHERE conditions are effectively associative and commutative (hence the ANSI-89 "join in the where" syntax) so actual order doesn't matter

    Logical order becomes important with outer joins and more complex queries: applying WHERE on an OUTER table changes the logic completely.

    Again, it doesn't matter how the optimiser does it internally so long as the query semantics are maintained by following logical processing order.

    And the key word here is "optimiser": it does exactly what it says

提交回复
热议问题