2

If I make a query as follows:

SELECT *
FROM TableA A INNER JOIN TableB B ON A.AID = B.AID
  INNER JOIN TableC C ON B.BID = C.BID

Does the INNER JOIN with TableC add significantly to the performance of the query? Will it attempt to do the join, or will it note the empty set of records and move on?

1 Answer 1

1

The order in which tables are joined isn't defined in the query (unless you use a join hint, which I wouldn't recommend), so you can't be sure that A is joined to B before B is joined to C.

To answer your question, in most cases SQL Server can tell from the statistics on the table (or other criteria) that the query won't return any rows. In that case, another JOIN won't make any difference from a pure performance perspective.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.