Press "Enter" to skip to content

Curated SQL Posts

T-SQL Tuesday 202 Round-Up

Marlon Ribunal summarizes a group of outages:

I expected stories about bad queries, failed deployments, storage problems, or maybe a database that decided to have a very bad day. What I got was much more interesting.

There were stories about ransomware, corrupted databases, deleted storage, power and cooling failures, an identity column reaching its limit, and even a floppy disk. A server Meltdown too.

Some of these outages lasted hours. Others lasted days or even weeks.

Click through for the list.

Leave a Comment

Tracking Online Index Rebuild Progress

Rich Benner doesn’t take 0% for an answer:

Ever had a situation where you’re rebuilding a large index but when you check sp_whoisactive, you see 0% complete … and you know the system is just lying to you?

We recently had a scenario where we were rebuilding a large index for a customer over a long weekend. We were monitoring closely, as this has caused production issues in the past. After 2.5 hours, we did not see any progress on the rebuild.

Read on to see what you can use to estimate the progress.

Leave a Comment

Tracking Changes in Power BI Semantic Models

Chris Webb wants to know what changed:

Here’s a situation I’ve found myself in many times. You’re called to help someone whose Power BI report is suddenly very slow. You ask whether any changes were made to the semantic model around the time performance got worse and the answer is no, absolutely not. You then spend anything from a few hours to a few days trying to fix the problem and when you find it, it turns out that someone did make a ‘minor’ change to the semantic model after all and this was the cause of it all. Wouldn’t it be good if you could see when things like measures were last changed? Well you can.

Click through to see how, as well as some challenges you might run into along the way.

Leave a Comment

Building an Azure DevOps Extension for Microsoft Fabric

Kevin Chant gives us the rundown:

When I first released the extension, I decided to keep the source code private. Having invested significant time developing and testing it, I wanted to first establish the extension.

Now that the source code is available in a GitHub repository I decided to share my experiences to help others create their own Azure DevOps extensions. Because there is more to creating an extension then just modifying the source code.

Click through for Kevin’s lessons learned.

Leave a Comment

Taking T-SQL Snapshot Backups on AG Secondaries

Andrew Pruski takes a backup:

One of my favourite features of SQL Server 2022 was the T-SQL Snapshot Backups. The ability to leverage the snapshot capabilities of modern storage arrays to take application consistent snapshots of our databases is a game changer for anyone dealing with very large databases and struggling to hit their RPO within their RTO.

However, application consistent snapshots require the write IO of the database to be quiesced/frozen/stunned…and (rightly so) this can make DBAs nervous.

SQL Server 2025 introduced the ability to take full and differential backups of secondary replica databases in availability groups…but what about the T-SQL Snapshot Backups? Wouldn’t it be great if we could take those on the secondary and not have to stun IO on the primary database?

But Andrew didn’t stop there, so click through to see how you can do it.

Leave a Comment

Automating SQL Server Benchmarking via HammerDB and Docker

Anthony Nocentino makes an announcement:

I’m excited to announce the release of a new open-source project that fully automates HammerDB benchmarking for SQL Server using Docker. If you’ve ever needed to run TPC-C or TPC-H benchmarks multiple times, you know how time-consuming the manual setup can be. This project removes the hassle and gets you up and running a single command: ./loadtest.sh.

Click through to learn more and to grab the code.

Leave a Comment

Animating How JSON Indexes Work

Brent Ozar has a new animation:

Let’s use the Users table from the Stack Overflow database, and let’s pretend that the Users.Location column is stored as JSON rather than letting users type in whatever they want. Let’s pretend we make them pick their Country, Province, and City. Then, let’s use one of my Database Animations to illustrate the pain of querying it without the JSON index, and then the cake-y-ness of the added index:

Brent also has an issue with the phrase “have your cake and eat it too” but I think it’s a proper phrasing that relies on a temporal understanding and pushing a past-tense verb into the present. The idea is that you cannot simultaneously have eaten your cake, while also maintaining it for later. I can understand Brent thinking the common phrase is a temporal slight of hand, but that one never bothered me.

The one that has bothered me for decades is “the proof is in the pudding.” The proper aphorism is “the proof of the pudding is in the eating.” The latter actually makes sense, whereas the former is an abbreviation that changes the meaning so much enough to remove most of its value as a folksy saying.

Leave a Comment

Making a Minimally Intrusive Schema Change

Jerry Nixon performs a change:

Schema change is inevitable. We do not get everything right the first time, and even when we do, the world around the database keeps changing. Requirements mature, products evolve, and assumptions that made sense years ago eventually stop matching reality.

Businesses change too. We acquire companies, merge with other customers and systems, enter new markets, and adapt to new opportunities. Sometimes a schema has to change because the original design was wrong. More often, it changes because the business is no longer the same business that existed when the schema was designed.

That is normal. The challenge is not avoiding schema change. The challenge is making those changes without interrupting the applications and users that depend on the database.

Click through for an example of a schema migration. I disagree with Jerry about doing the work in “the application,” mostly because it’s rarely one application controlling a database. If it is, and if there are no automated jobs, ad hoc PowerShell scripts, secondary applications, or other processes in place that could write data to the same database, then fine. But I typically find that to be less common than the alternative.

Leave a Comment

The Pain of Time Zones

Erik Darling makes an admission:

Erik Darling here with Darling Data, and in this video, we’re going to talk about mostly AT TIME ZONE performance, but also some other interesting stuff about AT TIME ZONE. I’m going to be real honest with you, I hate timezone stuff. I hate all of it. I’ve never taken naturally to it. It’s all too weird, and managing it is just such a nightmare. 

I agree with Erik’s point about storing everything in UTC. Click through to learn how you can slow things down considerably using AT TIME ZONE in certain ways.

Leave a Comment

Monitoring Microsoft Fabric Capacity Usage

Gilbert Quevauvilliers performs some measurements:

Before using Fabric Capacity operation events, you need to have a Fabric capacity.

In my testing, Capacity Operation Events consumed approximately 230,000 CUs per day.

Based on my usage, an F4 capacity was required to run this continuously each day.

NOTE: This is based on my usage. Your consumption may be slightly higher or lower.

That’s a fair amount of capacity to track how much capacity you’re using.

Leave a Comment