SELECT C.*
FROM Content C
INNER JOIN ContentPack CP ON C.ContentPackId = CP.ContentPackId
AND CP.DomainId = @DomainId
…and:
SELECT C.*
FROM Content C
INNER JOIN ContentPack CP ON C.ContentPackId = CP.ContentPackId
WHERE CP.DomainId = @DomainId
Is there any performance difference between this 2 queries?
Because both queries use an INNER JOIN, there is no difference — they’re equivalent.
That wouldn’t be the case if dealing with an OUTER JOIN — criteria in the
ONclause is applied before the join; criteria in theWHEREis applied after the join.But your query would likely run better as:
Using a JOIN risks duplicates if there’s more than one
CONTENTPACKrecord related to aCONTENTrecord. And it’s pointless to JOIN if your query is not using columns from the table being JOINed to… JOINs are not always the fastest way.