Execution Strategies and Runtime Behavior

Joins, parallel execution, memory grants, spills, and adaptive execution.

93 associated posts89 primary posts

Performance Tuning

Row-Level Security Can Slow Down Queries. Index For It.

The official Azure SQL Dev's Corner blog recently wrote about how to enable soft deletes in Azure SQL using row-level security, and it's a nice, clean, short tutorial. I like posts like that because the feature is pretty cool and accomplishes a real business goal. It's always tough deciding where to draw the line on how much to include in a blog post, so I forgive them for not including one vital caveat with this feature.

Read more about Row-Level Security Can Slow Down Queries. Index For It. 3 comments — Join the discussion
T-SQL & Development

Update: SQL Server 2025’s REGEX Performance Isn’t So Bad!

Back in March 2025 when Microsoft first announced that REGEX support was coming to SQL Server 2025 and Azure SQL DB, I gave it a quick test, and the performance was horrific. It was bad in 3 different ways:

The CPU usage was terrible, burning 60 seconds of CPU time to check a few million rows
It refused to use an index
The cardinality estimation was terrible, hard-coded to 30% of the table

Read more about Update: SQL Server 2025’s REGEX Performance Isn’t So Bad! 14 comments — Join the discussion

SSMS v22 Query Hint Recommendation Tool: The Invasion of the Query Hints

SQL Server Management Studio 22 Preview 3 is out, and it brings with it a new Query Hint Recommendation tool. Start by highlighting the query you want to test, then click Tools, Query Hint Recommendation Tool. It slides out a new pane on the right hand side: The maximum tuning time defaults to 300 seconds,…

Read more about SSMS v22 Query Hint Recommendation Tool: The Invasion of the Query Hints 24 comments — Join the discussion

Review: SSMS Copilot vs Other AI Tools

I use AI tools constantly in my work, so when the new SSMS v21 came out with Copilot support, I was excited to try it. The short story is that the user interface is fine, and it doesn't feel buggy, but the advice is simply terrible compared to other LLMs due to the prompt Copilot is using. You're better off using tools like ChatGPT, Gemini, and Claude directly for now.

Read more about Review: SSMS Copilot vs Other AI Tools 25 comments — Join the discussion
Performance Tuning

Query Exercise Answer: What Makes SELECT TOP 1 or SELECT MAX Different?

This Query Exercise was very different: I didn't ask you to solve a particular problem. I pointed out that I've heard advice that SELECT MAX is faster than SELECT TOP 1, and that's not quite true. I asked you to find factors that would cause these two queries to get different execution plans: [crayon-6a6eb81681575145979007/] In the…

Read more about Query Exercise Answer: What Makes SELECT TOP 1 or SELECT MAX Different? 4 comments — Join the discussion

[Video] Office Hours: Ask Me Anything About Azure and Microsoft Databases

Back at home in the office, time to settle in with a nice caffeine-free Diet Coke and go through your top-voted questions from https://pollgab.com/room/brento. Why caffeine-free? Because I slug multiple coffees first thing in the morning when I wake up (usually around 3am-4am), and by the time I stream with y'all, I don't need any more go juice.

Read more about [Video] Office Hours: Ask Me Anything About Azure and Microsoft Databases 4 comments — Join the discussion

Should You Use SQL Server 2022’s GREATEST and LEAST?

If you've been following along with this week's posts on DATETRUNC and STRING_SPLIT, you're probably going to think the answer is no, but bear with me. It's Christmas week, right? The news can't all be bad.

GREATEST and LEAST are kinda like MAX and MIN, but instead of taking multiple rows as input, they take multiple columns. For example:
[crayon-6a6eb81681b5b985913119/]
Produces 3 and 1. This actually has really useful real-world implications.

Read more about Should You Use SQL Server 2022’s GREATEST and LEAST? 2 comments — Join the discussion