Press "Enter" to skip to content

Curated SQL Posts

Ways to Find a Query Plan

Deborah Melkin has a list:

I’m very excited for this because I’ve wanted to put something together about this topic for a long time.

What inspired me is that I’ve really come to appreciate that there’s different pieces of information collected with the execution plan itself depending on where I get the plan from. Understanding what’s collected, where, and why can help make a difference when trying to troubleshoot and performance tune.

I get most of my query plans from a shady vendor with an unmarked van in a Walmart parking lot.

Leave a Comment

Dealing with linger.ms in Apache Kafka

Jack Vanlightly covers a common performance optimization:

Recently I was curious to see if there was any general performance improvement since Kafka 3.X. So I ran a suite of benchmarks with Dimster against 3.7.2 and 4.3.0. I saw two common patterns:

Those two patterns involved higher latency for the newer version of Kafka, but better scale. Click through to understand what changed between these two versions that had such a big impact.

Leave a Comment

Applying Different Formatting Rules at Levels of a Hierarchy

Marco Russo and Alberto Ferrari format things differently:

A challenging requirement in Power BI reports is that of applying different formatting rules based on the level of aggregation. At the year level, the background shade may reflect each year’s share of the grand total. At the quarter level, a status color may indicate whether the quarter is above or below the average. At the month level, the color may flag exceptional values, like months that contribute more than a defined threshold to their year. Each level has its own logic; what the conditional expression of the measure needs to know is which level the current cell belongs to.

Read on to see how you can pull this off.

Leave a Comment

Bad Query Signals

Mala Mahadevan takes advantage of an extra week:

I just managed to get a post in for this landmark T-SQL Tuesday, hosted by Brent Ozar. Brent was kind enough to keep the submission window open for two weeks instead of the usual one, and I was able to sneak a post in last – minute.

His invitation is to write about the things that immediately stand out as “bad signs” when reviewing a SQL query.

Click through for Mala’s list. It’s a good list. While some items Mala calls out are defensible and quite reasonable, there are some of them (such as a LEFT OUTER JOIN whose columns show up in the WHERE clause for filtering) that are simply not.

Leave a Comment

Writing Semantic Model Column and Measure Descriptions

Kurt Buhler shares some thoughts:

In a Power BI semantic model you can set freeform text fields for each object (like tables, columns, and measures) to describe what they do, how to use them, or other information. These descriptions are a convenient and structured way to document each object for developers. They’re also helpful for users, since the descriptions (unlike DAX expressions) show when you hover on the object in Power BI Desktop:

Click through to see what Kurt recommends in terms of items that should go into a description, as well as things that do not belong there. Kurt also has some strong ideas around AI-generated descriptions and what makes a description relatively more useful for a person versus a language model.

Leave a Comment

A Primer on Database States

Jeff Iannucci lays out the list:

I’ve recently been asked by some folks about different states for SQL Server databases. Questions like “what’s the state of a database with log shipping?”,  “can I fix a database in (whatever) state with a restart?”,  and “which is the bad one, RECOVERY or RECOVERY PENDING?”

Hopefully you don’t have to try to figure out if your database is in a bad way or not because of an unusual state, but I presume when you do you will need to know as soon as possible. So, I’ve put this handy list of possible database states together to help you in your moment of need.

Click through for the full set.

Leave a Comment

SQL Login Overhead in SQL Server 2025

Sean Gallardy has a wonderful rant:

There were a few emails about login times so I figured it warranted a blog post. Strap in, this one goes sideways fast.

Some people noted that the amount of time to log in with a SQL Login in SQL Server 2025 all of a sudden took longer. This is clearly stated in the Docs, though the way it is written is documented is problematic.

As Sean mentions, this is on purpose and it is good. Yeah, the amount of time it takes to log in using SQL authenticated accounts in SQL Server 2025 is higher. That’s because the mechanism to log in is now considerably more secure than it was before. And let’s be honest: how frequently are you logging into SQL Server? What percentage of your processing time does that take? Because if the answer is “a large percentage,” that sounds like a job for connection pooling or revising the calling application.

2 Comments

Checking Query Options from Query Store

Michael Bourgon sets ANSI_PADDING:

We know that SQL Server can cache multiple query plans for the same query based on the SET_OPTIONS for that query, and that SSMS doesn’t have the same options as the standard library. (https://www.sommarskog.se/query-plan-mysteries.html). He even includes a chart!

My initial comment was “Michael Bourgon sets XACT_ABORT” but that’s actually not one of the list, so I had to change it for the sake of correctness even though I think it was funnier in its original guise.

Leave a Comment

Direct Lake Mode Benefits in Power BI

Chris Webb lays out the pros:

This is a blog post I’ve been meaning to write for a long time. Since Fabric launched there has been a lot of focus on Direct Lake mode in Power BI and a lot of people used it because it was the cool new thing. Arguably, we at Microsoft have been guilty of telling people to use it because it was the cool new thing without properly explaining what the benefits are of using it. Direct Lake doesn’t completely replace other storage modes: in a recent post I talked about when Import/DirectQuery composite models are the best choice; Marco wrote a good article on Direct Lake vs Import mode which makes the case for the continuing relevance of Import mode for many scenarios. So what are the main benefits of using Direct Lake mode? 

Click through for Chris’s answer.

Leave a Comment

Performing a Lakehouse Table Health Check

Jon Lunn looks at a stored procedure:

Microsoft have rolled out a new ‘sys’ stored procedure called ‘sys.sp_get_table_health_metrics’ for checking the health of your tables in your Lakehouse. And it outputs a lot of metrics looking at the state of your table and anomaly detection in them.

What does it check for?

Click through for that answer, as well as some of the things you should watch for in the procedure results, and what you can do if it does catch something.

Leave a Comment