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


Query tuning performance


Query tuning performance

Author
Message
maneeshkrverma
maneeshkrverma
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 49
how can we get execution plan of a query executed on two different days so that i come to know that what is cause of slowing down the query today? i know that query was running fine one week back.

what are the steps to find the cause of slowing down the query today which was running very well in past?

what could be the possible reason of slowing down the query today which was running very well in past?

I have faced this question in interview lot of time could you please help me?
durai nagarajan
durai nagarajan
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3411 Visits: 2784
Query slowness is due to serveral reasons

poor Statistics or index or disk or network need to have run trace and identify .

for interview questions you have get through experience not an answer from experts.

Regards
Durai Nagarajan
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96551 Visits: 33013
There is no way to go back in time to retrieve an execution plan. So, if you have a need to monitor particular plans, you need to set up, ahead of time, a mechanism for capturing those plans. When I have to do this, I generally use extended events. It is possible to use a server-side trace, but they put a lot of load on the server. You can also query directly into the cache using the Dynamic Management Objects. But you'll have to set all this up.

Conversely, if you know the query has a problem now, capture the plan (see above) and save it. You can save plans as .sqlplan files. Then, either wait for performance to go back to normal or force a recompile on the query in order to see if changing circumstances change the plan. Compare what's there to what you captured.

But, performance may not be about plans changing. It could be about differences in statistics, the amount of data, blocking, etc. So all this comes back to having monitoring in place to be able to track system performance and behavior.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Erland Sommarskog
Erland Sommarskog
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5090 Visits: 875
There are a multitude of possible reasons why the query started to run slower.

But a very common scenario is that you have a query which involves something like "today's orders". When statistics have recently been updated, the optimizer can deal that there are a fair share of orders today and will arrive to a plan accordingly. But as the week moves on, statistics are not updated, neither manually, nor automatically beause the table is too big to trigger autostats very often. Now when you ask for today's orders, the optimizer looks at the statistics and finds nothing and estimate 1 order. And then it goes downhill from there.

Often yoy may be lucky; if the query is inside a stored procedure stays in cache for a long time, why the bad statistics does not matter. But one day, the plan goes out of cache for whatever reason, for instance a server restart.

Erland Sommarskog, SQL Server MVP, www.sommarskog.se
Dennis Post
Dennis Post
SSC Eights!
SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)

Group: General Forum Members
Points: 953 Visits: 547
Check out : http://ola.hallengren.com/
Learn the and understand the code.
When you do, you'll have no worries with these questions again.



For better, quicker answers on T-SQL questions, read Jeff Moden's suggestions.

"Million-to-one chances crop up nine times out of ten." ― Terry Pratchett, Mort
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40556 Visits: 20000
Dennis Post (9/10/2013)
Check out : http://ola.hallengren.com/
Learn the and understand the code.
When you do, you'll have no worries with these questions again.


Where in the linked site can I find out how to interpret and compare execution plans, Dennis?

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Dennis Post
Dennis Post
SSC Eights!
SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)SSC Eights! (953 reputation)

Group: General Forum Members
Points: 953 Visits: 547
Unsure
Hmm good point Chris.
Not sure why I posted that.
Good to keep indexes defragmented and statistics up to date though....



For better, quicker answers on T-SQL questions, read Jeff Moden's suggestions.

"Million-to-one chances crop up nine times out of ten." ― Terry Pratchett, Mort
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