Index tuning and query hinting give us one plan that works well enough for some situations, but what if we really need two different plans? For example, we’ve been dodging around the problem of two different input parameters that really require two different approaches: maybe it’s small data versus big data, maybe it’s two different…
Search Results for “sp_blitz”
1.3 The Drawbacks of Using Recompile Hints
So far, we’ve added indexes, broken up queries into sections to encourage SQL Server to use those indexes, and even added query-level hints, all in an effort to get one execution plan that works well enough for most scenarios. But what if you can’t? Recompile hints are so compelling because they get a brand new…
3.1 How Memory Grant Feedback Multiplies Parameter Sniffing
On day 1, we implemented monitoring to start collecting plans having parameter sniffing issues. To keep things simple, we kept the compatibility level at 2017. Now let’s start exploring the features that SQL Server 2019 brings to the table – in spirit, they’re supposed to help SQL Server adapt to varying amounts of data moving…
2.3 Tracking Even More Plan Cache Details with Query Store
The method of logging sp_BlitzFirst/Cache/Who to table will probably give you everything you need to troubleshoot the majority of parameter sniffing situations. However, sometimes you need to gather even more data, and you’re willing to pay a performance price to get it. Query Store is a built-in feature that can track dramatically more of the…
2.4 Lab 3: Track Down Plans & Parameters
Now, it’s your turn: we’re going to run a workload in your lab while sp_BlitzFirst collects data and Query Store runs. You’ll query the plan cache history in DBAtools.dbo.BlitzCache and BlitzWho, find queries whose plans are changing, and gather parameters & plans to use that will help you design a better plan tomorrow. You don’t…
2.1 Spotting Wild Variations in the Plan Cache
In order to detect, troubleshoot, and prevent parameter sniffing issues, we’re going to need: Metrics about how queries are performing Different versions of the query plans that caused those metrics To collect them, we’re going to go from the lowest-overhead, least-data solutions first, and then gradually progress to the collection methods that have the highest…
06. What Triggers Parameter Sniffing Emergencies, Part 2
There are 3 specialized causes for parameter sniffing: unparameterized queries flooding the plan cache, memory pressure due to query workspace grants, and plans aging out of the cache. Demo Script Transact-SQL /* Fundamentals of Parameter Sniffing What Triggers Parameter Sniffing Emergencies, Part 2 v1.2 – 2020-08-04 https://www.brentozar.com/go/snifffund This demo requires: * SQL Server 2016 or…
[Video] Watch Brent Write T-SQL
Bonus: Abnormal Parallelism
In another module in this class, we explain normal ranges of CXPACKET, CXCONSUMER, and LATCH_EX that you’ll see during a typical workload. We how to mitigate “normal” parallelism waits with changes to Cost Threshold for Parallelism and MAXDOP. However, I say that just by changing those two settings alone, you may still run into abnormal…
[Video] Updated First Responder Kit and Consultant Toolkit for May 2020
Free Webcast on Dynamic SQL Pro Tips
08. Lab: Tackle a Parameter Sniffing Emergency
The phones are ringing, the users are screaming, and your manager is dropping four-letter words. The server’s performance has tanked, and you’re the one on call. Start up a workload, find the query who suddenly got a terrible plan, and do the needful. Part 1: Setting Up the Lab Part 2: Your Mission Part 3:…
07. How to React to Parameter Sniffing Emergencies
Remember the things we discussed in the last module? Restarting the service, rebuilding indexes, updating stats, and freeing the entire plan cache? Yeah, don’t do that. You solve the parameter sniffing emergency for one query, but you cause a parameter sniffing emergency for the rest of ’em – because now all the other queries are suddenly getting…
09. What Parameter Sniffing ISN’T
Some things get mistaken for parameter sniffing issues when they’re unrelated. For example, when you run the same query in two different environments and get two different plans, it might not have anything to do with the parameters at all: the data distribution might be different in the two environments, or they might have different…
05. What Triggers Parameter Sniffing Emergencies, Part 1
The biggest problem with parameter sniffing isn’t that SQL Server can produce different plans. The real problem is that the plans change unexpectedly, seemingly out of nowhere, with. no advanced warning. However, armed with an understanding of what triggers plans to be evicted from the cache, you can start to predict when these emergencies will…
01. What Parameter Sniffing Is
We’ll start by defining what parameter sniffing is: a query that builds a dramatically different plan depending on what parameters are first used to compile it. We’ll begin with a query that uses literal values, show two different parameters that produce different plans, and show what happens when it’s put into a stored procedure. Demo…
[Video] Can You Tell When a Rollback Will Finish?
Why Ordering Isn’t Guaranteed Without an ORDER BY
Want SQL Server Training? Copy/Paste This Email To Your Boss.
[Video] How Can I Measure If My Database Does More Reads Than Writes?
Hi! I’m Brent Ozar.
I make Microsoft SQL Server go faster. I love teaching, travel, cars, and laughing. I’m based out of Las Vegas. He/him. I teach SQL Server training classes, or if you haven’t got time for the pain, I’m available for consulting too.
Want to advertise here and reach my savvy readers?