2. 1. DB Consultant Approaches
2. Fetching Execution Plans
3. Common execution plan patterns
4. Understand the data distribution
5. Q&A
Welcome.
Microsoft Services
helps businesses
around the world
maximize their return
on investment in
Microsoft products
and technologies.
12/28/2015 2
3. Proactive
Approach
12/28/2015 3
• Leverage MDW
• Have a Performance Baseline
Understand the load
• Missing Indexes
• Duplicate Indexes
• Unused Indexes
Understand the Indexing
• Leverage Plan hash and Query Hash to find
top resource intensive queries
• Leverage MDW to identify the top queries
Fetch Top Queries for Tuning
4. Reactive
Approach
12/28/2015 4
• Leverage MDW /SQLNexus to identify the resource
contention
Identify the Top Bottlenecks
• Leverage Plan hash and Query Hash to find top
resource intensive queries
• Leverage MDW to identify the top queries
Identify the Top Resource intensive queries
• Set Statistics IO ON
• Set Statistics Time on
• Set Statistics Profile on
Explore the execution plans
8. Cardinality
Estimation
12/28/2015 8
• Beauty lies in the data
• There is never a coincidence
• Wrong Estimation cause Hash
warnings/sort warning or almost
every mess up
• It’s the biggest gotcha while
query tuning
• Try to investigate the numbers
Show Demo on basic SQL Execution
Estimated Vs Actual
Show the Parametrized query and explain how they can get the parameters out of the execution plan
Get the query hash and plan hash Only zero cost plans are not shown here
Get the execution plan from the sys.dm_exec_query_plans and sys.dm_exec_query_stats
Hash warning sort warning - everything happens due to wrong cardinality estimation
Show Demo for
Basic Query Execution.sql
Improving cardinality estimation
Also tell everything is dependant on statistics
4. What if we don’t have statistics , how many rows will be estimated
5. Always keep your statistics updated
6. Auto create stats and auto update stats enable