When creating a query that joins 2 tables. I thought of 2 possible ways to write the query.
Below is a simplified example. Could you please let me know which would be faster?
SELECT t1.a,
t2.a
FROM table1 t1
JOIN table2 t2
ON t1.b = t2.b
WHERE t2.c = 'test'
OR
SELECT t1.a,
t2.a
FROM table1 t1
JOIN (SELECT a, b
FROM table2
WHERE c = 'test') t2
ON t1.b = t2.b
They should give exactly the same plan.
SQL Server will easily transform one to the other. Checking the execution plan is the only way to know for sure though.