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
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.ID
as
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
Sachin SinghPosted Jul 28, 2022, 8:35 AM
Vishal YelvePosted Jul 28, 2022, 7:48 AM
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).