Sometime during joining couples tables i seen that condition criterias placed are inside ON() clause, and sometime out of it, means after WHERE.
What approach is more optimized and faster in big amount of data ?
What will be faster
1.
SELECT a.column1, b.column2
FROM tablea a
JOIN tableb b
ON a.column3 = b.column3
WHERE b.column2='Y' AND a.column1='N'
or this one
2.
SELECT a.column1, b.column2
FROM tablea a
JOIN tableb b
ON (a.column3 = b.column3 AND b.column2='Y')
WHERE a.column1='N'
There are two ways of joining:
1/ SQL-89-style, using comma separated tables and the
WHEREclauseExample:
2/ SQL-92-style, using the
JOIN ... ONclauseExample:
The 92 style is more modern and is preferred, because the join is actually much more visible when reading the query. You can mix both styles, and it will work, but that is a terrible idea.
About performance, I can not do better than an already existing answer on Stackoverflow. I will quote the gist of it:
(emphasis mine)