Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eugene Meidinger Execution Plans

Similar presentations

Presentation on theme: "Eugene Meidinger Execution Plans"— Presentation transcript:

1 Eugene Meidinger Execution Plans 101 @sqlgene

2 About me Certified in querying and administering SQL Server Spoken at Pittsburgh SQL User Group and SQL Saturdays Worked for All-Lines / Lantek for 4 years Went from SQL newb to SQL pro Couldn’t distinguish stored procedure from a view Don’t go to the afterparty. You could end up like me!

3 Our programs will reduce IT costs, improve performance of the network, and assure a consistent level of service. Managed Services We provide assessment, design, implementation, management, monitoring, and computer support services for all business computing needs. IT Consulting SharePoint and Office 365 give you and the people you work with a better way to get things done together. Microsoft Solutions We provide IT staffing services for a variety of industries in the local market including manufacturing, finance, healthcare, among others. IT Staffing Our Services All Lines/LANtek is the only IT Services company in the region able to deliver the full range of services we can. From hardware to hosting we can keep your business efficient and in top production. We provide proofs of concepts and assessments in all of these areas. We can also provide demos on site at our data center in Warrendale. Enterprise Infrastructure

4 What is this talk about? What is an execution plan How to view an execution plan What does a plan look like How to read one Demo BONUS???? Resources

5 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 What is an execution plan?

6 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

7 What does a plan look like?

8 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 How to read an execution plan

9 Reading the Arrows

10 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

11 Basic Operators Select Top Sort Compute Scalar

12 Scans and seeks Scan versus seek 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

13 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

14 Missing index SQL Server will suggest an index if needed Use with caution

15 Comparing Queries Query Cost – Relative to Batch Run multiple queries to compare them

16 Demo

17 Bonus Slides! – SQL Plan Explorer

18 Bonus Slides! – Live Execution Plans

19 Bonus Slides! – Fooling the estimator When “Estimated rows” goes horribly wrong Example by Kendra Little when-row-estimates-get-high/ when-row-estimates-get-high/

20 Adventure Works Database Execution Plan Basics by Grant Fritchey Execution Plan Basics SQL Server Execution Plans, Second Edition by Grant Fritchey SQL Server Execution Plans, Second Edition SQL Plan Explorer by SQL Sentry SQL Plan Explorer Resources

21 Evaluations Session Evaluation sessionevaluation.aspx Event Evaluation

Download ppt "Eugene Meidinger Execution Plans"

Similar presentations

Ads by Google