Download presentation
Presentation is loading. Please wait.
1
Execution plans Eugene Meidinger @sqlgene www.sqlgene.com/powerbi/
2
About me Business Intelligence developer
Worked for All-Lines for 5 years Spoken at Pittsburgh SQL User Group and various SQL Saturdays Help lead the Pittsburgh Power BI User Group Pluralsight Author Went from SQL newb to SQL pro
3
Why are execution plans important?
They are simple to use They are key to improving query performance They give you insight to the database engine
4
What is an execution plan?
Instructions for how to process a query Can think of it as a recipe Created by the query optimizer at run time Execution plans are cached after the first run Many different ways to process the same query For trivial queries, a simple plan is used Can be forced with hints Don’t try to outsmart the database engine
5
How to view the execution plan?
Go to Query Click Include Actual Execution Plan Or, Press Ctrl + M Or click the execution plan icon on the toolbar
6
What does a plan look like?
7
How to read an execution plan
Read from right to left and top to bottom Icons represent operators Operators have cost below them Arrows represent data flow Bigger arrows represent more data Hover over icons and arrows for more detail
8
Reading the Arrows
9
Reading the Popup box Focus on the top, bottom, cost and estimated versus actual Top explains the operator Bottom is the important detail Est vs. Act can be a problem The rest isn’t important yet
10
Missing index SQL Server will suggest an index if needed
Use with caution
11
Comparing Queries Query Cost – Relative to Batch
Run multiple queries to compare them
12
Types of operators Gathering Data Joining Data Manipulating Data MISC
13
Gather data Table scan Clustered index scan Clustered index seek
Nonclustered index scan Nonclustered index seek RID lookup Key lookup
14
Scans and seeks Scan versus seek Clustered versus nonclustered
Scan – Going through all of the rows Seek – Going to a specific row Clustered versus nonclustered Clustered – using the whole table Nonclustered – taking advantage of the index Tables versus heaps Key Lookup – uses the primary key to find a row RID Lookup – uses the row number in a heap to find a row
15
Joins Merge Join – Joins two sorted datasets
Nested loop join – Loops a small data set over a larger one Hash join – A hash table is made with the smaller input
16
Manipulate data Filter Top Sort Compute Scalar
17
Demo
18
SQL Server Execution Plans, 2nd edition
19
SentryOne Plan Explorer
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.