Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL 2005 - Long duration Stored Procedure


SQL 2005 - Long duration Stored Procedure

Author
Message
balasach82
balasach82
SSC-Addicted
SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)SSC-Addicted (459 reputation)

Group: General Forum Members
Points: 459 Visits: 1079
I use a Stored Procedure (with parameter) which uses 3/4 joins to retrieve some fields.i.e., a select from 3/4 tables. The problem is whenever the SP is executed for a particular input for the first time, it takes 5 to 6 mins to retrieve records(1 to 100). But the same SP for the same parameter after that completes in a shorter duration. If the parameter is changed, then it takes similarly long time, but the second execution for the same parameter in shorter duration.

Execution plan does not have any table scan.
There are indexes present in all the tables.
recompiling SP, Freeing cache does not have desired effect.
SQL 2005

Any recommendations?
SQLRNNR
SQLRNNR
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21113 Visits: 18259
balasach82 (3/19/2010)
I use a Stored Procedure (with parameter) which uses 3/4 joins to retrieve some fields.i.e., a select from 3/4 tables. The problem is whenever the SP is executed for a particular input for the first time, it takes 5 to 6 mins to retrieve records(1 to 100). But the same SP for the same parameter after that completes in a shorter duration. If the parameter is changed, then it takes similarly long time, but the second execution for the same parameter in shorter duration.

Execution plan does not have any table scan.
There are indexes present in all the tables.
recompiling SP, Freeing cache does not have desired effect.
SQL 2005

Any recommendations?


Freeing cache will make it slower on the next run as well.

Do you have appropriate indexes?

Have you checked for parameter sniffing?

how do the statistics appear for your tables?

How is the index fragmentation level?



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

MANU-J.
MANU-J.
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1712 Visits: 8766
http://www.databasejournal.com/features/mssql/article.php/3841271/T-SQL-Best-Practices--Parameter-Sniffing.htm

MJ
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search