Assuming that I have the following T-SQL code:
SELECT * FROM Foo f
INNER JOIN Bar b ON b.BarId = f.BarId;
WHERE b.IsApproved = 1;
The following one also returns the same set of rows:
SELECT * FROM Foo f
INNER JOIN Bar b ON (b.IsApproved = 1) AND (b.BarId = f.BarId);
This might not be the best case sample here but is there any performance difference between these two?
No, the query optimizer is smart enough to choose the same execution plan for both examples.
You can use
SHOWPLANto check the execution plan.Nevertheless, you should put all join connection on the
ONclause and all the restrictions on theWHEREclause.