Solved

SP is taking time while execution. Need to fine tune for faster execution

Posted on 2010-11-13
5
338 Views
Last Modified: 2012-08-13
I am trying to execute an SP attached with this question usp-importbossdevice.sql.
The sp picks data from one table and Insert/Update/Delete data in destination table based on some rules/criteria/condition. The sp also exports data in destination table to a log table for archive purpose. There are calls to another sp for generating device id, user id and spare id.
There are 5000 rows is source table and 8000 rows in destination table.
When i execute the sp it is taking lot of time. I stopped the sp after 15 minutes. I am not able to see the exact problem
0
Comment
Question by:maheshpappu
5 Comments
 
LVL 7

Expert Comment

by:celazkon
Comment Utility
Hi, create indexes in the tables before running the procedure.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
To be honest, it is not surprising it is taking so long.  The Stored Procedure executes in a loop which is the worst way to execute any SQL Query.  Perhaps that is the only practical way you can do it, if that is the case than you are simply SOL.

So to summarize, if you are not prepared to re-write the whole Stored Procedure using good practices with set operations instead of looping for every row, than no amount of tweaking is going to yield any big differences.

Good luck.
0
 
LVL 6

Accepted Solution

by:
subhashpunia earned 500 total points
Comment Utility
0
 
LVL 8

Expert Comment

by:dba2dba
Comment Utility
You can use DTA to get some index recommendations for the procedure.

http://www.exforsys.com/tutorials/sql-server-2005/sql-server-database-tuning-advisor.html

0
 

Author Closing Comment

by:maheshpappu
Comment Utility
the tips provided will partially help in writing a proper sp. But  this is not the solution to the problem mentioned above.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now