Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Problems with Inner-Join Performance

Author  Topic 

UnitedOne
Starting Member

1 Post

Posted - 2015-04-09 : 17:05:26
Hi @ all,

I have a big problem with the performance of one of my queries.
The performance of the following query is very low:

Select * from RankingPassthroughs
Inner Join KeywordPassthroughs on RankingPassthroughs.Id = KeywordPassthroughs.RankingPassthroughId
Inner Join KeywordPassthroughRankings on KeywordPassthroughRankings.PassthroughId = KeywordPassthroughs.Id
Inner Join Keywords on KeywordPassthroughs.KeywordId = Keywords.Id
Inner Join KeywordRankingsUrls on KeywordPassthroughRankings.UrlId = KeywordRankingsUrls.Id
where KeywordPassthroughRankings.DomainId = 88


But if I reduce the query to

Select * from RankingPassthroughs
Inner Join KeywordPassthroughs on RankingPassthroughs.Id = KeywordPassthroughs.RankingPassthroughId
Inner Join KeywordPassthroughRankings on KeywordPassthroughRankings.PassthroughId = KeywordPassthroughs.Id
Inner Join Keywords on KeywordPassthroughs.KeywordId = Keywords.Id
where KeywordPassthroughRankings.DomainId = 88


or

Select * from RankingPassthroughs
Inner Join KeywordPassthroughs on RankingPassthroughs.Id = KeywordPassthroughs.RankingPassthroughId
Inner Join KeywordPassthroughRankings on KeywordPassthroughRankings.PassthroughId = KeywordPassthroughs.Id
Inner Join KeywordRankingsUrls on KeywordPassthroughRankings.UrlId = KeywordRankingsUrls.Id
where KeywordPassthroughRankings.DomainId = 88


the performance is perfect.

What's wrong with the first query?

Thank you!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-04-09 : 18:14:53
Show us the execution plan in XML format plus the statistics IO. You're likely missing some indexes, or maybe a bad execution plan.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -