Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans...
Transcript of Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans...
![Page 1: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/1.jpg)
Performance Tuning with
Execution Plans
![Page 2: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/2.jpg)
GOAL
• Show where, how and why
performance issues appear within
execution plans in order to better
understand how to use execution
plans to troubleshoot SQL Server
query performance
![Page 4: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/4.jpg)
Today’s Agenda
• Introduction to Execution Plans
• Common T-SQL Code Smells
• Worked Examples
• Querying the Plan Cache
• More Worked Examples
• Parameter Sniffing
• Additional Tools
![Page 5: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/5.jpg)
Introduction to Execution
Plans
![Page 6: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/6.jpg)
![Page 7: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/7.jpg)
Execution Plans
• Execution plans are a representation
of the processes used by the query
engine to perform the query
submitted to SQL Server.
![Page 8: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/8.jpg)
Relational Engine
QUERY
RESULT
Relational
Engine
Query
Parsor
Syntax Check
Parse
Tree
Algebrizer
Resolves Objects
Query
Processor
Tree
Optimizer
Execution
Plan
Query
Processor
QUERY OPTIMIZER
![Page 9: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/9.jpg)
Optimizer
• Cost-Based– Just an estimate
– Not based on your computer
• Statistics– Defined in indexes and tables
– Must be maintained to ensure a good execution plan
• Cache– Every query goes to cache (almost)
![Page 10: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/10.jpg)
Generating a Plan
• SQL Server Management Studio– Estimated
– Actual
• Procedure Cache– Estimated (sort of)
• Extended Events– Estimated
– Actual
• Trace Events (not recommended)– Estimated
– Actual
![Page 11: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/11.jpg)
Tune the QuerySmall to medium, look at the query first
Medium to large, go straight to the execution plan
Very large and insane, query the execution plan
Watch for low-hanging fruit
Fix syntax over statsStats over indexing
Indexing over restructuringRestructuring
Read the execution plan
Understand the business needs
![Page 12: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/12.jpg)
Where To Start?
![Page 13: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/13.jpg)
Where To Start?
![Page 14: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/14.jpg)
First Operator
• Plan size
• Compile time
• Memory grant
• Missing Indexes
• Optimization level
• Parameter– Compiled value
– Runtime Value
• Query hash
• Reason for early termination
• ANSI settings
![Page 15: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/15.jpg)
Right to Left or Left to Right?
• A clue: English
• Another clue: These things
![Page 16: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/16.jpg)
Left to Right or Right to Left
• Answer: Both
• Logical processing order: – Represents how the optimizer sees the query
– Reading it from Left to Right
• Physical processing order– Represents the flow of data
– Follow the arrows/pipes from Right to Left
• Both are necessary to understand certain plans
![Page 17: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/17.jpg)
What Else to Look For
• Warnings
• Most Costly Operations
• Fat Pipes
• Extra Operations
• Scans
• Estimated vs. Actual
![Page 18: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/18.jpg)
Demo
![Page 19: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/19.jpg)
Summary
• Execution plans are your view into the optimizer
• You can capture plans multiple ways
• You start with the first operator
• Additional things to look for include:– Warnings
– Most costly operations
– Fat pipes
– Extra operations
– Scans
– Estimated vs. Actual
• Remember that these are just representations
![Page 20: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/20.jpg)
Common T-SQL Code
Smells
![Page 21: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/21.jpg)
![Page 22: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/22.jpg)
Code Smells
• A code smell is a piece of code that
functions, but doesn’t function in the
best possible way within a given set
of circumstances
![Page 23: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/23.jpg)
T-SQL Code Smells
• Functions on Predicates
• Data Conversion (Implicit & Explicit)
• Cursors
• Nested Views
• IF Logic
• Multi-Statement Table-Valued User Defined Functions
![Page 24: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/24.jpg)
Demo
![Page 25: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/25.jpg)
Worked Examples
![Page 26: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/26.jpg)
Demo
![Page 27: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/27.jpg)
Querying the Plan
![Page 28: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/28.jpg)
![Page 29: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/29.jpg)
Execution Plans From
CacheSELECT TOP 10
SUBSTRING(dest.text, (deqs.statement_start_offset / 2) + 1,
(CASE deqs.statement_end_offset
WHEN -1 THEN DATALENGTH(dest.text)
ELSE deqs.statement_end_offset
- deqs.statement_start_offset
END) / 2 + 1) AS querystatement,
deqp.query_plan,
deqs.query_hash,
deqs.execution_count
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_query_plan(deqs.plan_handle) AS deqp
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.total_elapsed_time DESC;
![Page 30: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/30.jpg)
Inside Execution PlansSELECT DB_NAME(deqp.dbid),
SUBSTRING(dest.text, (deqs.statement_start_offset / 2) + 1,
(CASE deqs.statement_end_offset
WHEN -1 THEN DATALENGTH(dest.text)
ELSE deqs.statement_end_offset
END - deqs.statement_start_offset) / 2 + 1) AS StatementText,
deqs.statement_end_offset,
deqs.statement_start_offset,
deqp.query_plan,
deqs.execution_count,
deqs.total_elapsed_time,
deqs.total_logical_reads,
deqs.total_logical_writes
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_query_plan(deqs.plan_handle) AS deqp
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
WHERE CAST(deqp.query_plan AS NVARCHAR(MAX)) LIKE '%StatementOptmEarlyAbortReason="TimeOut"%';
![Page 31: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/31.jpg)
Interesting Dynamic
Management Objects• Sys.dm_exec_query_plan
• sys.dm_exec_query_profiles
• Sys.dm_exec_text_query_plan
![Page 32: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/32.jpg)
Demo
![Page 33: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/33.jpg)
Additional Resources
• Sp_whoisactive – Adam Machanic
• Diagnostic Queries – Glen Berry
• Performance Tuning with SQL Server
Dynamic Management Views – Louis
Davidson and Tim Ford
![Page 34: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/34.jpg)
More Worked Examples
![Page 35: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/35.jpg)
Demo
![Page 36: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/36.jpg)
Parameter Sniffing
![Page 37: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/37.jpg)
http://download.red-
gate.com/ebooks/SQL/eBook_Perform
ance_Tuning_Davidson_Ford.pdf
![Page 38: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/38.jpg)
Parameter Sniffing
• It’s a good thing… except when it
isn’t
• Automatic
• Only works on parameters (with an
exception)
• It’s all about statistics
– Average vs. Specific
Parameter list in execution plan
![Page 39: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/39.jpg)
Bad Parameter Sniffing
• Differentiate from parameter sniffing
• Still about statistics
• Intermittent
• Different plans
• Focus on the compiled value
• Compare to runtime
• When it’s bad, it’s very bad
![Page 40: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/40.jpg)
Local Variables
• Eliminate parameters
• Turn parameters into local variables
• Produces “generic” plan
![Page 41: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/41.jpg)
Variable Sniffing
• The exception to parameters
• Same process
• Only works in a recompile situation
• Invisible killer or guardian angel
![Page 42: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/42.jpg)
OPTIMIZE FOR <value>
• Specific and accurate
• Changes over time
• Produces “precise” plan
![Page 43: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/43.jpg)
OPTIMIZE FOR
UNKNOWN• For when you’re not sure
• Changes over time
• Produces “generic” plan
![Page 44: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/44.jpg)
WITH RECOMPILE
• Specific every time
• Increases overhead
• May be more costly than
![Page 45: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/45.jpg)
Statistics
• After all, it’s all about the statistics
• Stats can age w/o updating
• You may have auto-update turned
off
• Sampled updates may be
inadequate
• Filtered statistics may help
![Page 46: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/46.jpg)
Plan Guides
• Just a different way to use hints
• Produces whatever plan you define
![Page 47: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/47.jpg)
Turn Sniffing Off
• Dangerous choice
• Last for a reason
• Very dangerous
• Turns it all off
• Everywhere
• Did I mention it’s dangerous?
![Page 48: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/48.jpg)
Demo
![Page 49: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/49.jpg)
Additional Tools
![Page 50: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/50.jpg)
![Page 52: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/52.jpg)
SQL Sentry Plan Explorer
• Application
• Free and Paid Version
• Easy to Use
• Extensive Funtionality
![Page 53: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/53.jpg)
Query Store
• Azure SQL Database
• SQL Server 2016
• Guaranteed to change how you
monitor and tune queries
![Page 54: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/54.jpg)
Demo
![Page 55: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/55.jpg)
Conclusion
![Page 56: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/56.jpg)
Tune the Query
• Small to medium, look at the query first
• Medium to large, go straight to the execution plan
• Very large and insane, query the execution plan
• Watch for low-hanging fruit
• Fix syntax over stats– Stats over indexing
• Indexing over restructuring– Restructuring
• Read the execution plan
• Understand the business needs
56
![Page 57: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/57.jpg)
![Page 58: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/58.jpg)
Resources
• Scarydba.com/resources
• SQL Server Execution Plans
• SQL Server Query Performance
Tuning
![Page 59: Performance Tuning with Execution Plans › wp-content › uploads › 2015 › 09 › ... · plans to troubleshoot SQL Server query performance. Let’s Talk scarydba.com grant@scarydba.com](https://reader034.fdocuments.net/reader034/viewer/2022042404/5f1ae9b09efdc23f9b18c38d/html5/thumbnails/59.jpg)
Rate This Session Now!Rate with Mobile App:
• Select the session from the
Agenda or Speakers menus
• Select the Actions tab
• Click Rate Session
Rate with Website:
Register at www.devconnections.com/logintoratesession
Go to www.devconnections.com/ratesession
Select this session from the list and rate it
Tell Us
What
You
Thought
of This
Session
Be Entered to
WINPrizes!
#ITDEVCON