SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Streamlining a Procedure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

latture
Starting Member

24 Posts

Posted - 03/04/2013 :  10:06:11  Show Profile  Reply with Quote
Hello. I have a massive procedure that's ran once a month which is now running 4+ hours. I need to fix this issue since. A year ago this procedure was running in 25 minutes. I was wondering if anyone can give me suggestions or direct me to a place where I can read about how to streamline this procedure. I think it's due to "Having" in the group by statement that's causing the delay but not certain... The procedure contains mutiple temp tables, updates, merge, and delete.

If someone is willing to take a look at the entire procedure I'll be more than happy to post it on here. I'm not posting the procedure on here sine this procedure is a beast and I didn't want to burden anyone too much. :)

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2047 Posts

Posted - 03/04/2013 :  10:24:01  Show Profile  Visit jackv's Homepage  Reply with Quote
A year ago it was running in 25 minutes. Have the data amounts changed? or is maintenance not maintained on this server.
Have you checked the Execution Plan of this procedure? Are there large scans? For example , are statistics updated?
Read this post for a troubleshooting a slow query.http://www.sqlserver-dba.com/2012/11/sql-server-how-to-troubleshoot-a-slow-running-query.html

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

TG
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 03/04/2013 :  10:45:47  Show Profile  Reply with Quote
One good thing to include on these "beast" type procedures which have many different statements is to capture some basic stats for every statement. That can be as simple as adding a "print getdate()" before each statement. If the procedure is called from another process then be sure to capture the output somewhere. for example if it is called by a job you can specify an output file. That way you can see which step(s) are taking the most time so you know where to focus your energy to correct the problem.

Be One with the Optimizer
TG

Edited by - TG on 03/04/2013 10:46:45
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000