SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Funny query executiin behaviour


Funny query executiin behaviour

Author
Message
Query Shepherd
Query Shepherd
Mr or Mrs. 500
Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)

Group: General Forum Members
Points: 564 Visits: 454
At one of my servers i got the funny problem, that sometimes one of my queries take 300 ms and at some times 8000 ms allthough the server has enough ressources. I can't explain this behaviour. What could be theoretical reasons for this?

Thanks in advance! God bless you!

Greetz
Query Shepherd
Sean Lange
Sean Lange
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64089 Visits: 17974
SQL Pizza (4/19/2013)
At one of my servers i got the funny problem, that sometimes one of my queries take 300 ms and at some times 8000 ms allthough the server has enough ressources. I can't explain this behaviour. What could be theoretical reasons for this?

Thanks in advance! God bless you!


Can you provide some more details? The theoretical reasons could be just about anything. Is this a stored proc? Are the stats up to date? Do you have nonSARGable predicates? The list could go on and on. At the very least providing the actual execution plan would be a good place to start.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Query Shepherd
Query Shepherd
Mr or Mrs. 500
Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)

Group: General Forum Members
Points: 564 Visits: 454
Oh man...if it wouldn't take me so long to obfuscate it. It's a normal query using cte to gather some values of 3 joined tables and the results get aggregated. I optimized the query over a long time playing around with different indexes and rewrote the query using different approaches. So the query is optimal with it's 300 ms. But sometimes the query takes 8000 ms allthough there's almost no load on the server. So I wanted to know if you got practical experiences with this behaviour?

Greetz
Query Shepherd
Sean Lange
Sean Lange
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64089 Visits: 17974
SQL Pizza (4/19/2013)
Oh man...if it wouldn't take me so long to obfuscate it. It's a normal query using cte to gather some values of 3 joined tables and the results get aggregated. I optimized the query over a long time playing around with different indexes and rewrote the query using different approaches. So the query is optimal with it's 300 ms. But sometimes the query takes 8000 ms allthough there's almost no load on the server. So I wanted to know if you got practical experiences with this behaviour?


Yes but I have no context to see what MIGHT be the issue. Is this a stored proc? There is not much hope of helping figure it out without some details. ;-)

My two best guesses with no information is parameter sniffing (if it is a proc) or stale statistics.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Query Shepherd
Query Shepherd
Mr or Mrs. 500
Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)Mr or Mrs. 500 (564 reputation)

Group: General Forum Members
Points: 564 Visits: 454
It's not a stored proc. You could be right concerning parameter sniffing. Do you know any article etc. explaining me why parameter sniffing could be so costly. 300ms to 8000ms, that's a word, isnt' it? Could you explain take me on a short deep dive a provide me a good link for further investigations?

Greetz
Query Shepherd
Neeraj Dwivedi
Neeraj Dwivedi
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2065 Visits: 1341
Here ...it might help you.

http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx
Sean Lange
Sean Lange
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64089 Visits: 17974
Gail Shaw has a two part series on her blog that is excellent.

http://sqlinthewild.co.za/index.php/2007/11/27/parameter-sniffing/

http://sqlinthewild.co.za/index.php/2008/02/25/parameter-sniffing-pt-2/

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
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