Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


What to look for in Execution plans when a query is slow ?


What to look for in Execution plans when a query is slow ?

Author
Message
Oracle_91
Oracle_91
Right there with Babe
Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)

Group: General Forum Members
Points: 774 Visits: 1742
Hi Pals,

Assuming the query execution is slow , I have collected the actual execution plan. What should I look for in the actual execution plan . What are the top 10 things I need to watch out for?

I know this is a broad and generic question but I am looking for anyone who is experienced in query tuning to answer this question.

Thanks in Advance.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47183 Visits: 44356
This may help. http://www.sqlskills.com/blogs/paul/query-plan-analysis-first-steps/
Also, grab a copy of Grant's Exec plans book, should be lots in there, more than you'll get as forum replies


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14942 Visits: 38929
Oracle_91 (12/20/2013)
Hi Pals,

Assuming the query execution is slow , I have collected the actual execution plan. What should I look for in the actual execution plan . What are the top 10 things I need to watch out for?

I know this is a broad and generic question but I am looking for anyone who is experienced in query tuning to answer this question.

Thanks in Advance.


actually a great question, and it makes me wish i had saved some images to backup some examples. seeing is understanding in things like this.

I'll start adding things, and i know my peers will pitch in with more.
in no particular order, here's some i can think of
» in an actual execution plan, for any node, if the actual number of rows is orders of magnitude higher than the estimated number of rows, the statistics on the table being used in that node are out of date.

»Table Scan : if it exists,the table is a heap, and could benefit from adding a clustered index. clustered is always better.

»key lookup: an index was used to find a reference to get an additional column value: adding or modifying an existing index to INCLUDE that column could help.

» the obvious, in your face missing index statement needs to be reviewed; it might be correct, or it might be that an existing index could be tweaked to resolve the same query.

»if a scalar function is being used at all int he query, since they scale poorly on large numbers of rows.

»if a cursor is being used at all, it's most likely doing RBAR when a set based solution could do the same work orders of magnitude faster.

»Index Scan: if an index scan was used, theres probably not an index that helps the query well enough to do an index seek

»the output list for a node: if it's using an index, maybe adding an index with to match the WHERE, and which has the INCLUDE columns found in the list might help


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47183 Visits: 44356
Lowell (12/20/2013)
» in an actual execution plan, for any node, if the actual number of rows is orders of magnitude higher than the estimated number of rows, the statistics on the table being used in that node are out of date.


Not necessarily. There's a number of other reasons for cardinality estimates being wrong


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14942 Visits: 38929
GilaMonster (12/20/2013)
Lowell (12/20/2013)
» in an actual execution plan, for any node, if the actual number of rows is orders of magnitude higher than the estimated number of rows, the statistics on the table being used in that node are out of date.


Not necessarily. There's a number of other reasons for cardinality estimates being wrong


oh yes, i agree; but it's certainly something to watch for.

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17569 Visits: 32254
For just getting started, these are the things that I immediately look at for a plan. Yeah, there are tons more details, but this is the starting point. I did a presentation on this at the PASS Summit and it's available here.

----------------------------------------------------
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
Oracle_91
Oracle_91
Right there with Babe
Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)Right there with Babe (774 reputation)

Group: General Forum Members
Points: 774 Visits: 1742
Hi Grant,

Thanks for that cool stuff. It would be a great help for any starter and want to dig deep dive.

I also thank Gail, Lowell for putting up all the nice information. Thanks very much.
Ed Wagner
Ed Wagner
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10215 Visits: 9549
I have read Grant's book SQL Server Execution Plans book and I would certainly recommend it.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44981 Visits: 39869
Grant Fritchey (12/20/2013)
For just getting started, these are the things that I immediately look at for a plan. Yeah, there are tons more details, but this is the starting point. I did a presentation on this at the PASS Summit and it's available here.


Freakin' awesome, Grant. You're such a good speaker.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
     Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17569 Visits: 32254
Jeff Moden (12/22/2013)
Grant Fritchey (12/20/2013)
For just getting started, these are the things that I immediately look at for a plan. Yeah, there are tons more details, but this is the starting point. I did a presentation on this at the PASS Summit and it's available here.


Freakin' awesome, Grant. You're such a good speaker.


Ha! Thanks Jeff.

----------------------------------------------------
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
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