Download presentation
Presentation is loading. Please wait.
1
Reading Execution Plans Successfully
Arthur Daniels Reading Execution Plans Successfully
2
SQL Saturday Madison Sponsors
Gold Silver
3
SQL Saturday Madison After Party! 6:30pm Madison’s 119 King Street Madison, WI 53703 PASS Summit (November 6th) $150 discount code: SSDISHN1C
4
Arthur Daniels Twitter: ArthurDanSQL www.DBA-Art.com
Database Administrator SAP Fieldglass Focuses on performance tuning “I don’t care how long my query takes as long as it returns results”
5
Overview Structure of the plan First operators
DBA-Art.com Overview Structure of the plan First operators Warnings and suggestions Manipulating an execution plan
6
DBA-Art.com Disclaimer: SQL Server 2014 and above AdventureWorks 2014
7
Your environment matters
DBA-Art.com Your environment matters Hardware SQL Settings Min and max memory Cost threshold for parallelism Max DOP SQL version
8
Structure: Graphical Execution Plan
DBA-Art.com Structure: Graphical Execution Plan What’s that?
9
Other execution plan features
DBA-Art.com Other execution plan features Flow and size of line
10
Graphical Execution Plan
DBA-Art.com Graphical Execution Plan Plan Operators Index Seek Index Scan Key Lookup
11
DBA-Art.com Where and what are they? Graphical Execution Plans are stored as XML SQL Server Management Studio (SSMS) Live Query Stats SQL Server Plan Cache Query Store?
12
DBA-Art.com The Plan Cache sys.dm_exec_cached_plans (2008) Plan cache contains estimates Emptied when server restarts
13
Plan cache demo 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.
14
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
15
DBA-Art.com Statistics Demo Open Statistics on IX_TransactionHistoryArchive_ProductID
16
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
17
Warnings and Suggestions
18
DBA-Art.com Implicit Conversion Why? In actual and estimated
19
Reading Implicit Conversions
DBA-Art.com Reading Implicit Conversions Demo
20
DBA-Art.com Missing Index Hints Execution plan will contain index suggestions Only the first missing index is shown Review missing index DMVs
21
DBA-Art.com Missing Indexes Demo
22
Manipulating an execution plan
DBA-Art.com Manipulating an execution plan Parallelism as operators Gather Streams Distribute Streams Repartition Streams
23
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
24
Conclusion Look at the warnings Start with the right side of the plan
DBA-Art.com Conclusion DBA-Art.com Look at the warnings Start with the right side of the plan Read the predicates to understand the operator Try to re-write the query
25
DBA-Art.com Questions? You can also contact me on or my website,
26
DBA-Art.com Useful links Finding Implicit Conversions in your Plan Cache Free graphical plan explorer:
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.