Sometimes the exact same query goes slow out of nowhere.
Your current fix is to update statistics, rebuild indexes, or restart the SQL Server. It works, but you don’t know why.
You’re facing a problem called parameter sniffing: SQL Server “sniffs” the first set of parameters for a query, builds an execution plan for it, and then reuses that same plan no matter what parameters get called. It’s been the bane of our performance tuning for decades, and it doesn’t appear to be going away anytime soon – in fact, in newer versions of SQL Server, it even gets worse!
In this one-day class, you’ll follow along with me in the Stack Overflow database on your own laptop or desktop as you learn:
- What kinds of queries are vulnerable to parameter sniffing
- How to test your code to see if it’s vulnerable
- Why tactics like rebuilding indexes and updating statistics fix one query, but make others worse
- How to proactively patrol your server to uncover the problems before they bring you down
This course is 100% demos: the only slides are the introductions at the start of the day, and the recap at the end of the day. The rest of the time, we’ll be working in SQL Server Management Studio. Roll up your sleeves and join me!
Let’s get started with the introductions:
- 0.1 Prerequisites Before the Class
- 01. What Parameter Sniffing Is
- 02. The Kinds of Queries That Are Susceptible to Parameter Sniffing
- 03. Mo Choices, Mo Problems
- 04. Lab: Write a Query that’s Susceptible to Parameter Sniffing
- 05. What Triggers Parameter Sniffing Emergencies, Part 1
- 06. What Triggers Parameter Sniffing Emergencies, Part 2
- 07. How to React to Parameter Sniffing Emergencies
- 08. Lab: Tackle a Parameter Sniffing Emergency
- 09. What Parameter Sniffing ISN’T
- 10. Class Recap
- Bonus: Storytelling Time