Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Same SQL statement executed with Different duration Expand / Collapse
Author
Message
Posted Monday, November 16, 2009 2:38 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, January 4, 2012 12:23 PM
Points: 12, Visits: 24
Hi,
I have one stand alone application which is using 'SQL Server 2005' as database.

I have some tables containing records around 50,000. Those tables are executed using Store procedures and Views.

In Database, Every time same store procedure takes different duration to execute (I have tracked time using SQL server profiler.). Several times same store procedure executed within 1 second or some time it takes 2 to 3 second.

It is impacting application performance.

Can anyone tell me what could be reason behind different execution time each time for same store procedure? How could I improve performance of database?
Post #819261
Posted Monday, November 16, 2009 2:45 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Friday, October 17, 2014 8:13 AM
Points: 9,926, Visits: 11,188
You haven't really given us much information to work with, so I'll guess:

In broad terms, SQL Server stores a query plan for the whole stored procedure. That plan will be tuned according to the values passed to the procedure as parameters the first time it is executed. If those particular parameter values are not typical, the server might store a plan which doesn't work as well when executed with different parameters. Google 'SQL Server parameter sniffing' more more information.

Alternatively, post some more details to get better answers.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #819264
Posted Monday, November 16, 2009 3:01 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, January 4, 2012 12:23 PM
Points: 12, Visits: 24
Hi Paul,

Thank you,

Actully i am facing this problem to all store procedue(Same store procedure with different parameters value), 'Select' statement and view.
Post #819270
Posted Monday, November 16, 2009 6:59 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 6:26 PM
Points: 20,732, Visits: 32,496
Without seeing the code not much we can do to help. It is possible that you are experiencing parameter sniffing.

Please read the first two articles I reference in my signature block below. Following the instructions in those articles will help you get much better help.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #819355
Posted Tuesday, November 17, 2009 1:44 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, January 4, 2012 12:23 PM
Points: 12, Visits: 24
Thanks Lynn
Post #819877
Posted Thursday, April 15, 2010 2:19 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, June 23, 2014 1:33 PM
Points: 70, Visits: 171
Its a massive subject, places to look are the estimated and the actual query plans, use profiler to see actually whats running on SQL, use perfmon to look at the server and see if anythings slowing down - cpu, buffer io, memory etc, use sp_who2 to see if there are locks knocking about, make sure the stats and indexes are up to date (make sure the tipping point of the index isn't being compromised). If you are using 2005 use the Performance Management download from MS. It contains a whole load of reports and stuff to have a look at. And dont forget the basics, well written SQL, simply coded looking at tables with minimal complexity will always perform better and more consistently than monsters!
Post #904380
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse