This slide deck is in support of the live and video classes held by Redgate Software as part of the Community Circle initiative. This series of classes is meant to teach you the tools that can help to make query tuning easier in SQL Server. There are a number of different tools, all part of the fundamental Microsoft Data Platform offering, that can be used to help tune queries. This class outlines those tools and their uses.
2. Goals
Understand the native tools available to aid in query tuning.Understand
Know how to apply which tools in a given situation in order to
better aid query tuning.Know
Learn how to use various tools in aid of performance tuning.Learn
15. Extended Events
Community
Resources
Erik Darling: https://t.co/gZeXA8DjTw
William Durkin: https://t.co/U1z9Huol0y
Jes Schultz: https://t.co/1rkEJArFhH
Swasheck https://swasheck.github.io/2016-11-28-index-rebuild-
reorg/
Marcin Gminski https://t.co/hwd2Kuq6i3
Greg Moore https://t.co/sCowdWifmY
Eduardo Pivaral
https://www.mssqltips.com/sqlservertip/5748/start-and-stop-
extended-events-sessions-automatically-using-sql-server-agent-
jobs/
DBATools https://t.co/LIgB6JaHBA
Gianluca Sartori https://t.co/AJTHp1tv6r
Aaron Bertrand https://t.co/Pt4gQ4pTtQ
Erin Stellato https://t.co/HUK0okH8Oz
Jason Brimhall https://jasonbrimhall.info/2015/09/08/learning-
extended-events-in-60-days/
Eric Cobb https://t.co/YvwFgrJJUe
16. Goals
Understand the native tools available to aid in query tuning.Understand
Know how to apply which tools in a given situation in order to
better aid query tuning.Know
Learn how to use various tools in aid of performance tuning.Learn
32. You control…
Turn it on or Off
Time to flush to disk
Size of storage
Days in storage
Plans per query limit
Automatic cleanup
Capture Mode
Aggregation Interval Length
35. Query Tuning
Opportunities
Changes in how
you monitor
New information
available
Bad parameter
sniffing
Cardinality
Estimation issues
Structural
problems leading
to plan differences
36. Upgrade
Opportunities
Restore your older database,
leave compatibility level in place
Turn on query store
Run your load
Switch compatibility level
Identify regressions & force plans
as needed
52. SSMS Tools
Stuff we are not
talking about
Data Collection
Database
Engine
Tuning
Advisor
3rd Party
Profiler
53. SSMS Tools
Stuff we could talk
about but won’t
Statistics
Database
Objects
3rd Party
Fragmentation
54. SSMS Tools
Include Client Statistics
Positives
History Comparisons
Consistent
across edits
Negatives
Inaccurate
Inconsistent
with other
data
Difficult to
capture
67. What is an
Execution Plan
An execution plan describes the set of
operations that the execution engine within
SQL Server needs to perform in order to
return the data or perform the action
required by a query.
75. Operator Metrics
Counts Per Thread
Actual Rebinds
Actual Rewinds
Actual Rows
Batches
Actual CPU MS
Actual End of Scans
Actual Executions
Actual Logical Reads
Actual Physical Reads
Actual Read Aheads
Actual Elapsed DMS
Actual Lob Logical Reads
Actual Lob Physical Reads
Actual Lob Read Aheads
Input Memory Grant
Output Memory Grant
Used Memory Grant
78. First Operator
Plan size Compile time
Missing
Indexes
Optimization
level
Parameter
• Compiled value
• Runtime Value
Query hash
Reason for
early
termination
ANSI settings
79. Where To Go,
What To Read
It’s all in the
Properties
Identify Node
ID
Combine plans
and metrics
Every operator
is unique (to a
degree)
Track output
from each
operator
88. Adaptive Query Processing 2017
Multi-Statement Table-
Valued Functions
Interleaved execution
No data modification
No CROSS APPLY
Marked in execution plan
Tracking through extended events
Batch Mode Memory
Grants
Literally revises memory grant
Batch Mode processing only
2x or greater on memory over 1mb
No RECOMPILE
Tracking through extended events
Batch Mode Adaptive Joins
Defers join choice
Batch Mode processing only
Hash or loop joins only
Tracking through Query Store
90. Adaptive Query Processing 2019
Approximate COUNT
DISTINCT
Minimum 1 million rows
Aggregates columns with high number of
distinct values
Approximation is acceptable
Row Mode Memory Grants
Literally revises memory grant
Batch and Row Mode processing
2x or greater on memory over 1mb
No RECOMPILE
Tracking through extended events
Batch Mode In Row Store
Query involves 100,000+ rows
Analytic operators
Relieves CPU binding
Columnstore not needed
Table Variable Deferred
Compilation
Gathers table variable row counts
Uses those to create execution plan