Which is Better ? Filter Condition in JOIN (or) WHERE Clause ?

  • The filter condition can be used either in JOIN clause, for example,

    SELECT *FROM TABLE1 INNER JOIN TABLE2 ON

    TABLE1.COLUMN1 = TABLE2.COLUMN2 AND

    TABLE1.COLUMN4 <> 'N' AND TABLE2.COLUMN6 ='N'

     

    (or) it can be used in WHERE Clause, for example,

    SELECT *FROM TABLE1 INNER JOIN TABLE2 ON

    TABLE1.COLUMN1 = TABLE2.COLUMN2

    WHERE

    TABLE1.COLUMN4 <> 'N' AND TABLE2.COLUMN6 ='N'

    Logically both seems to do the same job. But from performance point of view does any of the above have any impacts?

  • Just have a look at the execution plan.  I'm sure you'll find it to be the same in this case and I would assume 99.999% of the cases.  The remaining cases would be left join conditions in which case you may be asking for 2 different things.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply