|
We have a procedure (SQL 2005) that has recently been modified and it suddenly went from an hour of processing to 15 hours of processing. I'm not sure where to look to narrow down where the extra hit is coming from. I have looked a Profiler, but I didn't see anything obvious. (Translate as maybe doesn't know how to best use Profiler?) My next step will be to look at the execution plan but how do I get the plan without running this proc for another 15 hours? Any suggestions? P.S. The proc is about 4000 lines long and involves an inner and outer cursor. I didn't want to subject anyone to that.
(comments are locked)
|
|
Take a look at the estimated execution plan, try to find any types of scans. In Management studio you can use shortcut key CTRL + L You should also beware of this:
Incorrect indexes may be caused by:
+1 because you added all the bits I was typing :)
Aug 10 '10 at 07:19 AM
Matt Whitfield ♦♦
My only concern is the execution plan for a 4000 line sproc is going to be unreadable. Break it down and analyse each part of the sproc is going to be easier and more sensible IMO
Aug 10 '10 at 07:24 AM
WilliamD
I agree with you williamD (but I have seen worse) :)
Aug 10 '10 at 10:25 AM
Håkan Winther
(comments are locked)
|
That says it all, pretty much. Ok, so it's started to take a lot longer - so that's going to be something related to your recent changes. However, it's pretty likely that you will be able to get that procedure running much much much quicker if it was written in a set based way. I accept that you're probably not going to re-write a 4000 line proc, so other things you can try:
(comments are locked)
|
|
4000 lines & Cursors! That sounds like your problem. But to get you started: You say the sproc has recently been modified, this is the first place to start. What has changed? Have you changed table structure? Added lots of code to the sproc? Added lots more data to the underlying tables? Added any triggers to tables that are now slowing things down? The best way to go is to take the sproc apart, step by step and see what is going on (look at the execution plans for each part separately). If you can remove the cursors that will help - SQL Server was not designed for cursors and can do most things without them. What is your sproc doing in those 4000 lines, if you don't mind me asking? +1 because you had exactly the same reaction as me!
Aug 10 '10 at 07:19 AM
Matt Whitfield ♦♦
My reaction is worse. I think I need a lie-down from just imagining this SP... I'll leave this with you guys, as you're already way ahead of me.
Aug 10 '10 at 07:45 AM
ThomasRushton ♦
(comments are locked)
|
|
Was there additional logging added to the SPROC? Any additional I/O is exponentially bothersome within cursors. Has blocking increased? Are there multiple transactions in the SPROC or is it all wrapped up as one big one? Based on what has been said it looks like you need to alter your SPROC to tackle, say, 1/10th the data at a time and run it more. What kind of inputs/outputs are used with the SPROC?
Aug 10 '10 at 01:56 PM
Blackhawk-17
(comments are locked)
|
|
Consider using some diagnostic DMVs. Glenn Berry has some here for SQL 2008, and I am sure there are more on his site for 2005.
(comments are locked)
|
1 2 3 next page »


Did the increase in time taken to run directly coincide with the date/time of modification? If so, then what was the modification?