September 12, 2008 at 2:12 pm
if you want to venture into analyzing the execution plan of your proc, look for "Index Scan"... that will give you clues on indexes (or WHERE clauses...) that should be changed
September 15, 2008 at 5:58 am
Please find the attachment of the execution plan
September 22, 2008 at 6:54 am
samsql, I still need you to clarify what you're asking for when you mention cases.
- 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
September 22, 2008 at 9:16 pm
GSquared (9/22/2008)
samsql, I still need you to clarify what you're asking for when you mention cases.
He wants you to optimize the sections that have CASE statements for him too.
September 22, 2008 at 10:47 pm
Sam,
My recommendation is to peel one potato at a time. To know which potato to peel first, you must do some measuring. Put the following at the beginning of your code...
SET STATICSTICS TIME ON
Then, just before each section of Selects identifies by the rather sparse comments, add the following...
PRINT REPLICATE('=',120)
PRINT 'put a section name here'
That way, you can see which section(s) of code are taking the longest and you can concentrate on those first.
At the bottom of the code, add...
SET STATISTICS TIME OFF
Without know what's taking the longest or not, you have no real chance of ever getting this working right.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 23, 2008 at 7:25 am
Jeff Moden (9/22/2008)
My recommendation is to peel one potato at a time. To know which potato to peel first, you must do some measuring.
Gosh Jeff, you make it all sound so glamorous. 😛
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
September 23, 2008 at 8:10 am
Jeff Moden (9/22/2008)
Sam,My recommendation is to peel one potato at a time. To know which potato to peel first, you must do some measuring. Put the following at the beginning of your code...
SET STATICSTICS TIME ON
Then, just before each section of Selects identifies by the rather sparse comments, add the following...
PRINT REPLICATE('=',120)
PRINT 'put a section name here'
That way, you can see which section(s) of code are taking the longest and you can concentrate on those first.
At the bottom of the code, add...
SET STATISTICS TIME OFF
Without know what's taking the longest or not, you have no real chance of ever getting this working right.
I did a similar thing with a long running job a little while ago. Since it was running in batch and I couldn't easily run it interactively, at each break point, I wrote "Section Name_x" and "Date_time" to a table, then I could look at the table later and see how long each step took. .... It was quite helpful.
September 23, 2008 at 8:18 am
homebrew01 (9/23/2008)
Jeff Moden (9/22/2008)
Sam,My recommendation is to peel one potato at a time. To know which potato to peel first, you must do some measuring. Put the following at the beginning of your code...
SET STATICSTICS TIME ON
Then, just before each section of Selects identifies by the rather sparse comments, add the following...
PRINT REPLICATE('=',120)
PRINT 'put a section name here'
That way, you can see which section(s) of code are taking the longest and you can concentrate on those first.
At the bottom of the code, add...
SET STATISTICS TIME OFF
Without know what's taking the longest or not, you have no real chance of ever getting this working right.
I did a similar thing with a long running job a little while ago. Since it was running in batch and I couldn't easily run it interactively, at each break point, I wrote "Section Name_x" and "Date_time" to a table, then I could look at the table later and see how long each step took. .... It was quite helpful.
Why not use the profiler with sp:StmtStarting and sp:StmtCompleted in Stored Procedures Events / TSQL SQL:StmtStarting and SQL:StmtComplted for that particular Job to get the details instead of doing Print statements or writing to log table?
-Roy
September 23, 2008 at 8:22 am
Why not use the profiler with sp:StmtStarting and sp:StmtCompleted in Stored Procedures Events / TSQL SQL:StmtStarting and SQL:StmtComplted for that particular Job to get the details instead of doing Print statements or writing to log table?
I wasn't familiar with that, and since the job ran at night, it seemed like a pretty simple thing to set up.
September 23, 2008 at 8:08 pm
Roy Ernest (9/23/2008)
Why not use the profiler with sp:StmtStarting and sp:StmtCompleted in Stored Procedures Events / TSQL SQL:StmtStarting and SQL:StmtComplted for that particular Job to get the details instead of doing Print statements or writing to log table?
Absolutely correct... but have you looked at the code? There's about 10,000 Selects that look nearly identical.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 10 posts - 16 through 24 (of 24 total)
You must be logged in to reply to this topic. Login to reply