Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 General Discussion
»
Same SQL statement executed with Different...
Same SQL statement executed with Different duration
Rate Topic
Display Mode
Topic Options
Author
Message
Mayur-1130810
Mayur-1130810
Posted Monday, November 16, 2009 2:38 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, January 04, 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
Paul White
Paul White
Posted Monday, November 16, 2009 2:45 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 1:02 AM
Points: 10,989,
Visits: 10,534
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
Mayur-1130810
Mayur-1130810
Posted Monday, November 16, 2009 3:01 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, January 04, 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
Lynn Pettis
Lynn Pettis
Posted Monday, November 16, 2009 6:59 AM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 12:16 PM
Points: 21,621,
Visits: 27,455
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
Mayur-1130810
Mayur-1130810
Posted Tuesday, November 17, 2009 1:44 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, January 04, 2012 12:23 PM
Points: 12,
Visits: 24
Thanks Lynn
Post #819877
Paul Swinfield
Paul Swinfield
Posted Thursday, April 15, 2010 2:19 PM
Valued Member
Group: General Forum Members
Last Login: Thursday, May 16, 2013 6:51 AM
Points: 68,
Visits: 158
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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.