Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reading execution plans successfully

Similar presentations


Presentation on theme: "Reading execution plans successfully"— Presentation transcript:

1 Reading execution plans successfully
Arthur Daniels Reading execution plans successfully

2 October 30th Through November 3rd
Join the brightest data professionals focused on the Microsoft Data Platform! October 30th Through November 3rd Pre-Conference Sessions – Monday/Tuesday Conference – Wedneday through Friday

3 SQLSaturday #682 – After Party
4th Floor of Mall of America at 6:30 PM Sponsored By:

4 Thank you Sponsors! Platinum Sponsor: Gold Sponsors:

5 DBA-Art.com Twitter: @ArthurDanSQL
Presentation slides + demos Step-by-step instructions for setting up a test server at home:

6 DBA-Art.com Intro 3 years working with SQL Server Presented at SQL Sat Iowa City “I don’t care how long my query takes as long as it returns results”

7 Overview What makes up an execution plan?
DBA-Art.com Overview What makes up an execution plan? What do the operators inside the execution plan mean? What you can infer from your plan

8 My test environment SQL Server 2014 - Developer AdventureWorks 2014
DBA-Art.com My test environment SQL Server Developer AdventureWorks 2014

9 Your environment matters
DBA-Art.com Your environment matters Hardware SQL Settings Min Max Memory, Cost Threshold for Parallelism SQL version

10 Graphical Execution Plan
DBA-Art.com Graphical Execution Plan What’s that?

11 Other execution plan features
DBA-Art.com Other execution plan features Flow and size of line

12 DBA-Art.com Where and what are they? Graphical Execution Plans are stored as XML SQL Server Management Studio (SSMS) SQL Server Plan Cache Live Query Stats Query Store?

13 DBA-Art.com The Plan Cache sys.dm_exec_cached_plans (2008) Plan cache contains estimates Emptied when server restarts

14 Plan cache demo To-do: Build plan cache Find our specific plan
DBA-Art.com Plan cache demo To-do: Build plan cache Find our specific plan Look at operator View actual plan’s rows vs estimated.

15 Graphical Execution Plan
DBA-Art.com Graphical Execution Plan Plan Operators Index Seek Index Scan Key Lookup

16 Where do the estimates come from?
DBA-Art.com Where do the estimates come from? SQL Server automatically generates statistics One statistic per index One statistic per column once a query searches by that column Search as in Where clause, JOINs

17 DBA-Art.com Statistics Demo Open Statistics on IX_TransactionHistoryArchive_ProductID

18 Statistics General Used for execution plan estimates
DBA-Art.com Statistics General Used for execution plan estimates Automatically generated One for each index One for each column* Statistics contain header, density vector and histogram

19 Reading deeper Parallelism as operators
DBA-Art.com Reading deeper Parallelism as operators Gather Streams Distribute Streams Repartition Streams

20 Comparing a parallel query to serial query
DBA-Art.com Comparing a parallel query to serial query Demo Set Cost Threshold for Parallelism to 1 for this demo

21 Compute Scalar Operator
DBA-Art.com Compute Scalar Operator Used for mathematical expressions Referred to as “Expr”

22 DBA-Art.com Compute Scalar Demo Demo here

23 DBA-Art.com Implicit Conversion Why? In actual and estimated

24 Reading Implicit Conversions
DBA-Art.com Reading Implicit Conversions Demo

25 DBA-Art.com Missing Index Hints Execution plan will contain index suggestions Only the first missing index is shown

26 DBA-Art.com Missing Indexes Demo

27 Tools inside SQL Server 2016
Query Store Live Query Statistics

28 Conclusions

29 Wrap-Up How SQL estimates cost Operators: Index Scan, Index Seek
DBA-Art.com Wrap-Up How SQL estimates cost Operators: Index Scan, Index Seek Parallelism Compute Scalar Implicit Conversions Missing Indexes

30 Finally, what you can infer
DBA-Art.com Finally, what you can infer Look at size of lines between operators Discover what operators are doing Search your plan cache for hidden problems

31 DBA-Art.com Questions? You can also contact me on or my website,

32 DBA-Art.com Useful links Finding Implicit Conversions in your Plan Cache Free graphical plan explorer:


Download ppt "Reading execution plans successfully"

Similar presentations


Ads by Google