April 19, 2013 at 12:55 pm
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
April 19, 2013 at 12:58 pm
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 http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 19, 2013 at 1:05 pm
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
April 19, 2013 at 1:12 pm
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 http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 19, 2013 at 1:16 pm
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
April 19, 2013 at 1:27 pm
Here ...it might help you.
http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx
April 19, 2013 at 1:32 pm
Gail Shaw has a two part series on her blog that is excellent.
http://sqlinthewild.co.za/index.php/2007/11/27/parameter-sniffing/[/url]
http://sqlinthewild.co.za/index.php/2008/02/25/parameter-sniffing-pt-2/[/url]
_______________________________________________________________
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 http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply