CPU intensive query#2

Dear all,

I found out some SQL queries that make the CPU hight, tempdb usage hight and I dont' know how to solve, please comment.

FROM #VendorDD dd 				
JOIN @CountryCode cc ON dd.CountryCode = cc.CountryCode				
LEFT JOIN #DDRoot r1 ON dd.DialedDigits = r1.DD				
LEFT JOIN #DDRoot r2 ON dd.DestinationID = r2.AttributesID 				-- 2004.10.25 sg #7148-#7149
AND r2.AttributesID IS NULL				
AND	@EffDate BETWEEN dd.BeginDate AND ISNULL(dd.EndDate, @EffDate)


Open in new window

now the in the execution plan, what I can see the high cost is 2 x table scan, so how to solve it?

execution plan:

marrowyungSenior Technical architecture (Data)Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

can you provide:

a. the complete query, and
b. the complete execution plan (.sqlplan file, xml, not an image)


please note the second table scan is of an estimated 2 rows, but it is iterated 17109 times
so may not be the scan that is the problem, but the iterations

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marrowyungSenior Technical architecture (Data)Author Commented:
I can't find that plan anymore, I will start another question.
marrowyungSenior Technical architecture (Data)Author Commented:
as you proactive help me, then that;s why you get my award! I appreciate your help and I usually just want the helper and reader direct me to the right point of solving problem why is it.

and I will keep learning from you all.
marrowyungSenior Technical architecture (Data)Author Commented:
ok, tks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.