Plan Cache, Query Store, and Query Analysis

Using query history, cached plans, and runtime data to investigate performance.

200 associated posts60 primary posts

What Does Setting the SQL Server Compatibility Level Do?

If you right-click on a database in SQL Server Management Studio, you get an option to set Compatibility Level at the database level:

When you upgrade SQL Server or you want to improve performance, which option should you choose? Should you always go with the newest compatibility level? If you have an old application, can you upgrade SQL Server but still keep the old compat level without the vendor knowing? Let's hit the common questions.

Read more about What Does Setting the SQL Server Compatibility Level Do? 25 comments — Join the discussion
T-SQL & Development

#tsql2sday: Start Your Dynamic SQL with a Comment.

When you write dynamic SQL, start like this:
[crayon-6a70639989443116075660/]
Right after the SELECT (or INSERT or UPDATE or whatever), immediately put a comment - using /*, of course, because you're not a terrible person.

That way, when you're looking at the plan cache or monitoring tools, you can see what generated the dynamic SQL, and where you need to go if you need to performance tune or fix it.

Read more about #tsql2sday: Start Your Dynamic SQL with a Comment. 6 comments — Join the discussion
Production DBA

Erik Darling’s Month of Free Tools Training

Over the past month (plus or minus a couple days), Erik Darling churned out dozens of posts to show how he uses different SQL Server Community Tools that are free and open source to troubleshoot SQL Server issues. You should read all of them. I did. (I also shamelessly copy/pasted this intro, plus the below, directly from his blog.)

Read more about Erik Darling’s Month of Free Tools Training 4 comments — Join the discussion

Community Tools Month: Using sp_WhoIsActive to Catch ASYNC_NETWORK_IO

When your SQL Server's top wait stat is ASYNC_NETWORK_IO, that indicates SQL Server is waiting on the app to ask for the next part of the result set.

This is a real pain in the rear to troubleshoot because often these waits happen for really short duration each time - think milliseconds, not seconds. It's an issue of death by a thousand cuts.

Read more about Community Tools Month: Using sp_WhoIsActive to Catch ASYNC_NETWORK_IO 10 comments — Join the discussion
Performance Tuning

PSPO: How SQL Server 2022 Tries to Fix Parameter Sniffing

Parameter sniffing is a notorious problem for Microsoft SQL Server because it tries to reuse execution plans, which doesn't work out well for widely varying parameters. Here's a primer for the basics about how it happens. SQL Server 2022 introduces a new feature called Parameter Sensitive Plan optimization. I'm not really sure why Microsoft capitalized…

Read more about PSPO: How SQL Server 2022 Tries to Fix Parameter Sniffing 38 comments — Join the discussion
Production DBA

Office Hours, Text Edition: No-Brainer Questions

For my Office Hours streams on my Twitch channel, y'all post questions at PollGab and upvote the ones you'd like to see me discuss on the stream. However, not all questions require a video answer. Here are some simple no-brainer ones:

Q: BehindTheScenesDBA: With all its limitations, what do you think about memory-optimized tables? Have you recommended to a client to use it?

Read more about Office Hours, Text Edition: No-Brainer Questions 10 comments — Join the discussion

[Video] Office Hours: Ask Me Anything About SQL Server at the Volcano Hekla

I drove up the volcano Hekla in central Iceland - also known as the Gateway to Hell - and parked the Defender here:

While my travel companions hiked up higher (and took that photo), I set up the tripod and camera, then went through your highly-upvoted questions from https://pollgab.com/room/brento.

Read more about [Video] Office Hours: Ask Me Anything About SQL Server at the Volcano Hekla 2 comments — Join the discussion