Amour22015
asked on
MS SQL Server 2008 - Cleanup Stored Procedure
Hi,
I have attached a Stored Procedure (CleanupSP). This Stored Procedure takes 3.22 Hours to run. I would like to clean it up so it will run faster?. I did not create this, but someone told me that it deals with a vertical Table??? and that is why it is like it is???
Please Help and thanks
CleanupSP.docx
I have attached a Stored Procedure (CleanupSP). This Stored Procedure takes 3.22 Hours to run. I would like to clean it up so it will run faster?. I did not create this, but someone told me that it deals with a vertical Table??? and that is why it is like it is???
Please Help and thanks
CleanupSP.docx
for start: make sure to add appropriate indexes (run exec sp_helpindex for the tables in the query)
and insure DB maint task ran: reindex; update stats;checkdb
---
and review the code for CTE usage ( looks like it is a good candidate)
and insure DB maint task ran: reindex; update stats;checkdb
---
and review the code for CTE usage ( looks like it is a good candidate)
ASKER
Hi and thanks
First let me say that I am new to Stored Procedures.
So I am at a loss on the comments made?
SP runs M, T, W at night
It was mentioned:
Checking the organization of the primary table does it include historic data or does it employ archiving where at the conclusion of the year? Does your db use partitioning based on the year??
If the data does not change, and if you can spare the storage, the sp coud create tables that include the @taxyear in the name removing the drop section
The primary table (Main Table)
does not use historic data it is based on Tax Year which in this case is 2012
the other parts I am not sure how to answer?
Mentioned:
for start: make sure to add appropriate indexes (run exec sp_helpindex for the tables in the query)
and insure DB maint task ran: reindex; update stats;checkdb
---
and review the code for CTE usage ( looks like it is a good candidate)
Need step-by-step on how to do this???
Thanks for any help and Happy new year...
First let me say that I am new to Stored Procedures.
So I am at a loss on the comments made?
SP runs M, T, W at night
It was mentioned:
Checking the organization of the primary table does it include historic data or does it employ archiving where at the conclusion of the year? Does your db use partitioning based on the year??
If the data does not change, and if you can spare the storage, the sp coud create tables that include the @taxyear in the name removing the drop section
The primary table (Main Table)
does not use historic data it is based on Tax Year which in this case is 2012
the other parts I am not sure how to answer?
Mentioned:
for start: make sure to add appropriate indexes (run exec sp_helpindex for the tables in the query)
and insure DB maint task ran: reindex; update stats;checkdb
---
and review the code for CTE usage ( looks like it is a good candidate)
Need step-by-step on how to do this???
Thanks for any help and Happy new year...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
The sp constructs five tables from complex data aggregation.
Presumably you can not alter the database structure using triggers to maintain an upto date.
Using views would sacrifice performance for seemingly an infrequent run of the query.
Checking the organization of the primary table does it include historic data or does it employ archiving where at the conclusion of the year? Does your db use partitioning based on the year??
If the data does not change, and if you can spare the storage, the sp coud create tables that include the @taxyear in the name removing the drop section.