Parameter Sniffing on SQL Server

Slides:



Advertisements
Similar presentations
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
Advertisements

Understanding Parameter Sniffing Benjamin Nevarez Blog: benjaminnevarez.com 1.
Sponsored by: Professional Association for SQL Server Bad plan! Sit! Gail Shaw.
Dave Ballantyne Clear Sky SQL. ›Freelance Database Developer/Designer –Specializing in SQL Server for 15+ years ›SQLLunch –Lunchtime usergroup –London.
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
How to solve a SQL performance problem Paul Zgondea.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Learningcomputer.com SQL Server 2008 – Profiling and Monitoring Tools.
Srik Raghavan Principal Lead Program Manager Kevin Cox Principal Program Manager SESSION CODE: DAT206.
How to Use Parameters Like a Pro …and Boost Performance Guy Glantser, CEO, Madeira.
Maciej Pilecki | Project Botticelli Ltd.. SELECT Bio FROM Speakers WHERE FullName=‘Maciej Pilecki’;  Microsoft Certified Trainer since 2001  SQL Server.
Meta Data Cardinality Explored CSSQLUG User Group - June 2009.
Maciej Pilecki Consultant Project Botticelli Ltd. DAT404.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
OM. Platinum Level Sponsors Gold Level Sponsors Pre Conference Sponsor Venue Sponsor Key Note Sponsor.
Execution Plans Detail From Zero to Hero İsmail Adar.
SQL Server 2016 – New Features Tilahun Endihnew March 12, 2016.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
SQL Server Magic Buttons! What are Trace Flags and why should I care? Steinar Andersen, SQL Service Nordic AB Thanks to Thomas Kejser for peer-reviewing.
SQL Server Performance Tuning
SQL Server Statistics and its relationship with Query Optimizer
ASE Optdiag Features including dynamic_histogram
Data Virtualization Demoette… Packaged Query Single Select Option
Parameter Sniffing in SQL Server Stored Procedures
Query Optimization Techniques
Stored Procedures – Facts and Myths
Antonio Abalos Castillo
Things You Can Find in the Plan Cache.
Query Store What’s it all About? Andrew J. Kelly
Parameter Sniffing in SQL Server Stored Procedures
Mission-critical performance with Microsoft SQL Server 2016
The Top 5 SQL Server Mistakes
Peeking into the Plan Cache with SQL Server 2008
Introduction to Execution Plans
Query Execution Expectation-Reality Denis Reznik
Statistics And New Cardinality Estimator (CE)
Dynamics AX Performance
SQL Server 2017 has more cool features than just running on Linux
When I Use NOLOCK AND OTHER HINTS
Simple Partitioning Building a simple partitioning solution with SQL Server Stephen Fulcher.
Now where does THAT estimate come from?
Cardinality Estimator 2014/2016
Statistics What are the chances
Query Optimization Techniques
الحد من المشاكل السلوكية في رياض الاطفال
Statistics: What are they and How do I use them
When query plans go wrong
Hugo Kornelis Now where does THAT estimate come from? The nuts and bolts of cardinality estimation.
When I Use NOLOCK AND OTHER HINTS
Transact SQL Performance Tips
How to Use Parameters Like a Pro
In Memory OLTP Not Just for OLTP.
Parameter Sniffing: the Good, the Bad, and the Ugly
Introduction to Execution Plans
Parameter Sniffing: the Good,the Bad, and the Ugly
Name of Event Name of Event
When I Use NOLOCK AND OTHER HINTS
Parameter Sniffing: the Good, the Bad, and the Ugly
Insight into the SQL Server Buffer Cache
Ridewaan Hanslo ridewaanhanslo
Jean Joseph DBA\DEVELOPER
SQL Server Query Design and Optimization Recommendations
Introduction to Execution Plans
Query Optimization Techniques
T-SQL Basics: Coding for performance
Introduction to Execution Plans
Why should I care about SQL, if I have ORM?
Managing the mystery database
How to build a T-SQL Framework SQL Performance for Developers
Presentation transcript:

Parameter Sniffing on SQL Server Dean Savović Parameter Sniffing on SQL Server

Sponsor

Who am I Comminus d.o.o. Zagreb - Croatia Head of Data Management Department SQL Server MCSE 18 years of experience Conference speaker

Agenda What is parameter sniffing When is good? When is bad? How to deal with it when it is bad? Demo Conclusion

Let’s start

What is Parameter Sniffing? Ability of SQL Server Reuse execution plan from cache Less CPU and memory usage Important on high-load systems

When PS is good? Data distribution is even Cardinalities of sets of data execution plan deals with are similar

When PS is bad? Data distribution is not even Cardinalities are not similar Duration variation Reads variation

How to deal with bad PS? Optimize for unknown Trace flag 4136 ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = OFF Optimize for value Option recompile Dynamic sql Dynamic sql with parameters Dynamic sql with option recompile

Demo dbo.tQuestionnaire 3 m rows

Demo Name – non clust index Date Issued – non clust index

Demo dbo.proc_tQuestionnaire_Select

Demo exec dbo.proc_tQuestionnaire_Select @Name=N'Brighton',@DateIssued=default exec dbo.proc_tQuestionnaire_Select @Name=default,@DateIssued='2018-02-11 00:00:00'

Conclusions

Conclusions Most of the time PS is good Various methods to deal with bad parameter sniffing