Download presentation
Presentation is loading. Please wait.
1
When query plans go wrong
2
SQL
3
Simon Sabin Independent SQL Server Consultant and Trainer
Database design and development, Business Intelligence, Performance tuning and troubleshooting SQL Server since 6.5 Blog: Twitter: simon_sabin
4
Car crash
5
Works on my computer
6
Parameter Sniffing @
7
SQL tries to be clever
8
A bit like
9
Statistics
10
So what are the root causes
11
Out of date statistics Best Before: 1/4/1999
12
Skewed data
13
Multi purpose queries
14
Solutions Selective code paths WITH RECOMPILE OPTIMIZE FOR PLAN guides
Careful as SP is compiled as one batch WITH RECOMPILE Compilation hit, plan cache bloat OPTIMIZE FOR Results in a consistent plan PLAN guides
15
Update Statistics Update Statistics Trace flag 2388, 2389 and 2390
Can be a performance hit Trace flag 2388, 2389 and 2390
16
Overview Out of date statistics Compilation Best Query
Skewed Data Supportable Multiple Code paths Update statistics OPTIMZE FOR WITH RECOMPILE Trace Flags
17
Summary You will only know if you monitor Baseline your system
Identify changes in read, writes and cpu Not duration Consider the options for your situation You can win this battle
18
Please fill in feedback forms
Q&A Now - Just ask Afterwards – I’ll be around Much Later @simon_sabin Please fill in feedback forms
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.