I work on sql server 2019 i don't know which is best for performance filtering on where condition or filtering on join
with another meaning which is best
first query
SQL
select A.* from A
inner join B on A.ID=B.ID
INNER JOIN C ON C.ID=B.ID
WHERE B.name='Hazard'
OR
second query
select A.* from A
inner join B on A.ID=B.ID and B.name='Hazard'
INNER JOIN C ON C.ID=B.IDas
suppose table A have milion rows
table B have 2 milion rows
table c have 500 thousand rows
so which is best first query or second query

Vishal YelveRank #178 · 13.6K reputationPosted Jul 28, 2022, 3:48 AM EDT
Theoretically, no, it shouldn't be any faster. The query optimizer should be able to generate an identical execution plan. However, some database engines can produce better execution plans for one of them (not likely to happen for such a simple query but for complex enough ones). You should test both and see (on your database engine).
Sachin SinghRank #66 · 26.2K reputationPosted Jul 28, 2022, 4:35 AM EDT