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

Query tuning performance Expand / Collapse
Author
Message
Posted Wednesday, September 4, 2013 2:19 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, October 9, 2014 4:30 AM
Points: 10, 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?
Post #1491178
Posted Wednesday, September 4, 2013 2:30 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, May 30, 2014 8:15 AM
Points: 1,056, Visits: 2,687
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
Post #1491182
Posted Wednesday, September 4, 2013 3:54 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:26 PM
Points: 13,871, Visits: 28,266
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
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1491200
Posted Wednesday, September 4, 2013 3:46 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: Saturday, October 11, 2014 11:41 AM
Points: 806, Visits: 723
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
Post #1491559
Posted Tuesday, September 10, 2013 7:42 AM
SSC-Enthusiastic

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

Group: General Forum Members
Last Login: Thursday, March 6, 2014 1:35 AM
Points: 175, 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
Post #1493191
Posted Tuesday, September 10, 2013 7:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:59 AM
Points: 6,780, Visits: 13,980
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
Post #1493199
Posted Wednesday, September 11, 2013 4:25 AM
SSC-Enthusiastic

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

Group: General Forum Members
Last Login: Thursday, March 6, 2014 1:35 AM
Points: 175, Visits: 547

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
Post #1493554
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse