Is there any difference in terms of performance between these two versions of the same query?
--Version 1
SELECT p.Name, s.OrderQty
FROM Product p
INNER JOIN SalesOrderDetail s on p.ProductID = s.ProductID
--Version 2
SELECT p.Name, s.OrderQty
FROM Product p
INNER JOIN (SELECT ProductID, OrderQty FROM SalesOrderDetail) s on p.ProductID = s.ProductID
I've heard it said (by a DBA) that Version 2 is faster because it fetches, within the inner SELECT statement, only the columns that are required for the query. But that doesn't seem to make sense, since query performance (as I know) is based on number of rows affected and final list of columns returned.
The query plans for both are identical, so I'm guessing there isn't any difference between the two.
Am I correct?
You are correct. You did exactly the right thing, checking the query plan rather than trying to second-guess the optimiser. :-)