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

Funny query executiin behaviour Expand / Collapse
Author
Message
Posted Friday, April 19, 2013 12:55 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 31, 2014 10:27 PM
Points: 116, Visits: 347
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
SQL Pizza



sometimes you dont see the pizza for the toppings...
seek and ya shall find...
Post #1444566
Posted Friday, April 19, 2013 12:58 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:31 PM
Points: 13,302, Visits: 12,167
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 Moden's 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)
Post #1444568
Posted Friday, April 19, 2013 1:05 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 31, 2014 10:27 PM
Points: 116, Visits: 347
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
SQL Pizza



sometimes you dont see the pizza for the toppings...
seek and ya shall find...
Post #1444572
Posted Friday, April 19, 2013 1:12 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:31 PM
Points: 13,302, Visits: 12,167
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 Moden's 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)
Post #1444577
Posted Friday, April 19, 2013 1:16 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 31, 2014 10:27 PM
Points: 116, Visits: 347
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
SQL Pizza



sometimes you dont see the pizza for the toppings...
seek and ya shall find...
Post #1444579
Posted Friday, April 19, 2013 1:27 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 5:30 AM
Points: 811, Visits: 1,165
Here ...it might help you.

http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx
Post #1444585
Posted Friday, April 19, 2013 1:32 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:31 PM
Points: 13,302, Visits: 12,167
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 Moden's 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)
Post #1444586
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse