Solved

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

Posted on 2010-11-13
5
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 7

Expert Comment

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

Expert Comment

by:Anthony Perkins
ID: 34128796
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
ID: 34134981
0
 
LVL 8

Expert Comment

by:dba2dba
ID: 34138478
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
ID: 34194421
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

691 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