Search Results for “parameter sniffing”

Office Hours Speed Round, Easy Text Answers Edition

Some of the questions y’all post at https://pollgab.com/room/brento have easy one-line answers. Let’s knock ’em out: George: Hi Brent, what recently has been the most challenging/surprising/new-to-you performance issue you have encountered? SQL Server 2019’s slowdowns. I spent days working on that. RoJo: Have you used Distributed AG as a way to upgrade major versions of…
Read More

#tsql2sday: Start Your Dynamic SQL with a Comment.

T-SQL
6 Comments
When you write dynamic SQL, start like this: CREATE OR ALTER PROC dbo.MyProc AS BEGIN DECLARE @StringToExecute NVARCHAR(4000); SET @StringToExecute = N'SELECT /* MyProc */ '; ... 12345 CREATE OR ALTER PROC dbo.MyProc ASBEGIN DECLARE @StringToExecute NVARCHAR(4000); SET @StringToExecute = N'SELECT  /* MyProc */ '; ... Right after the SELECT (or INSERT or UPDATE or whatever),…
Read More

0.2 Download the Slides and Scripts

The slide deck and demo scripts (zip) is here (last updated 2022-06-15.) The slide deck is just a few slides that I use at the beginning and end of the class, not very useful for note-taking. The real meat is in the demo scripts in each module, and those are exactly the same in the…

Read More
Brent Reading Book

9 Signs Your T-SQL Might Fail a Code Review

T-SQL
28 Comments
It’s hard to set absolute rules about, “Feature X should absolutely never be used.” However, there are some features that set off alarm bells when I see them. Usually, when I start asking more questions about when we’re using those particular features, I get answers of, “Oh, I didn’t know that was a problem.” As…
Read More
Pocket Square

Updated First Responder Kit and Consultant Toolkit for September 2019

This month’s release has a lot of new feature goodness: the Consultant Toolkit can automatically upload the results to Amazon S3, plus sp_BlitzCache adds a new sort order to better catch unparameterized queries burning up CPU, a new warning for selects that are doing writes (other than >500MB spills, which we’ve been warning you about…
Read More
Telluride Colorado

Updated First Responder Kit and Consultant Toolkit for August 2019

sp_DatabaseRestore can now restore to Azure blobs and change the database owner after a restore, and everything else gets bug fixes. To get the new version: Download the updated FirstResponderKit.zip Azure Data Studio users with the First Responder Kit extension: ctrl/command+shift+p, First Responder Kit: Import. Download the updated Consultant Toolkit in your account EU customers:…
Read More

Is It a Code Problem or a Server Problem?

Your users are complaining that your SQL Server is slow – but is it a database problem, or not enough hardware? It’s confusing because the developers always blame the sysadmins, and the sysadmins always blame the developers. In one hour, you’ll learn: The 3 metrics to monitor on every SQL Server: Batch Req/Sec, Data Size,…
Read More
Brent Ozar's Consultant Toolkit

Updated First Responder Kit and Consultant Toolkit for April 2019

This month, lots of improvements and bug fixes, including checking for paused resumable index operations, Evaluation Edition expiration dates, sp_BlitzCache shows the number of duplicated plans for each query, sp_BlitzIndex will skip a list of databases for you, and more. To get the new version: Download the updated FirstResponderKit.zip Azure Data Studio users with the…
Read More

Why sp_prepare Isn’t as “Good” as sp_executesql for Performance

sp_prepare For Mediocre You may remember me from movies like Optimize for… Mediocre? and Why You’re Tuning Stored Procedures Wrong (the Problem with Local Variables)! Great posts, Kendra! Following the same theme, we found this issue while looking at queries issued from JDBC. Specifically, the prepared statement class seems to cause queries to hit the density vector…
Read More

Why You’re Tuning Stored Procedures Wrong (the Problem with Local Variables)

There’s an important rule for tuning stored procedures that’s easy to forget: when you’re testing queries from procedures in SQL Server Management Studio, execute it as a stored procedure, a temporary stored procedure, or using literal values. Don’t re-write the statemet you’re tuning as an individual TSQL statement using local variables! Where it goes wrong…
Read More