November 5, 2009 at 8:00 am
Hi,
Does anyone know if there is any difference in performance when you put your criteria with your INNER JOIN rather than in your WHERE clause?
For example:
SELECT t1.Id
FROM dbo.Table1 AS t1
JOIN dbo.Table2 AS t2 ON t1.Id = t2.Id
AND t2.Active = 1
Verses:
SELECT t1.Id
FROM dbo.Table1 AS t1
JOIN dbo.Table2 AS t2 ON t1.Id = t2.Id
WHERE t2.Active = 1
November 5, 2009 at 8:13 am
Probably no difference at all.
Check the execution plans for two queries like that, see if they're different in any way.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 5, 2009 at 9:38 pm
Vicki Peters (11/5/2009)
Hi,Does anyone know if there is any difference in performance when you put your criteria with your INNER JOIN rather than in your WHERE clause?
For example:
SELECT t1.Id
FROM dbo.Table1 AS t1
JOIN dbo.Table2 AS t2 ON t1.Id = t2.Id
AND t2.Active = 1
Verses:
SELECT t1.Id
FROM dbo.Table1 AS t1
JOIN dbo.Table2 AS t2 ON t1.Id = t2.Id
WHERE t2.Active = 1
Heh... why ask us?? Just try it.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 6, 2009 at 12:43 am
Inner join, no. Left/right join, they're two different queries with two different results, so performance isn't the issue....
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply