Press "Enter" to skip to content

Curated SQL Posts

When Ints Overflow

Aaron Bertrand hits an outage in both directions:

The Stack Overflow database has a long lineage, and a lot more warts than what’s exposed in Stack Exchange Data Explorer (SEDE). Many of the core tables were created a decade before I joined the staff in 2021, and they grew far larger than could have been envisioned back then.

One of those tables is UserHistory. This table uses an identity column as the clustered index and primary key, and records all kinds of information about each user’s activity on the site. From changing your profile picture, to earning a new privilege, to changing a preference, to something as simple as logging in or out. Each event generates at least one new row in UserHistory. At peak popularity, this table would grow quite quickly and, as the application became more complex, more and more categories of activity and state would get written there.

Click through for the story of an outage, and then another outage with a very similar shape.

Leave a Comment

DBAs as Cost Centers

Warwick Rudd lays out the bitter truth:

That has been the problem for as long as there have been database administrators, and I don’t think we’ve ever really solved it.

Here’s what I mean. A DBA doing the job properly produces nothing you can see. The environment is up. The queries return. Nobody rings anybody at two in the morning. And because nothing appears to be happening, the people looking after it start to look like a line of cost with nothing attached to it.

In the traditional sense of how businesses think about this, they’re right. Nothing a DBA does makes money. What a DBA does is save money, which is a much harder thing to put in front of a board.

Warwick’s post moves in the direction of managed services. I’d move in the direction of understanding and vocalizing the benefits you bring to the table as a DBA.

Leave a Comment

Scatter and Sampling in Power BI Core vs Deneb

Kerry Kolosko shows some comparisons:

In almost a decade of building Power BI reports, a common blind spot I still see from colleagues regards data point limits in core visuals — largely unnoticed until someone maps their data and finds entire regions are missing.

Compare the following lasagne plot created using a Power BI core visual scatterplot with one created using a Power BI custom visual (Deneb).

Click through for the difference. The more I see Deneb, the more impressed I am with it. I’ve seen people do some wild things with it while still working just fine in Power BI. There’s even compatibility with Power BI Report Server, if you can believe it.

Leave a Comment

Dealing with Outages

Jeff Taylor tells a pair of stories:

It was a normal day at the start, checking on the servers, responding to email, then all of a sudden the office went dark and silent…we had just lost power!

Everyone started stirring and then getting up, checking that our phone system was on backup power, and someone called the power company to report it and get a status of when the power would be back on.

Extreme heat, smoke, and servers are not a great combination.

Leave a Comment

Implementing SCD Type 2 in Microsoft Fabric

Nikola Ilic reminds us that the Kimball model is alive and well:

Slowly Changing Dimensions (SCD) are one of the fundamental concepts in dimensional modeling. If you are not sure what dimensional modeling is, I suggest you first check the series of articles I wrote on data modeling some time ago.

And, when it comes to SCD in particular, SCD Type 2 is rightly considered “the queen” of the SCDs for analytical workloads. Without going into details (since the main goal of this article is to show you HOW to implement the SCD Type 2 in Microsoft Fabric), I’ll just briefly introduce the general concept behind the SCD Type 2.

Click through for a primer and examples in the warehouse and lakehouse.

Leave a Comment

Azure Databricks and Power BI Storage Modes

Chris Webb makes a choice:

In case you haven’t already seen the blog post on the Power BI blog or the discussion on LinkedIn, we at Microsoft published a new white paper last week to help you decide which storage mode to use when you’re using Power BI to create semantic models and reports on data stored in Azure Databricks. You can find the announcement and the link to the paper here.

Click through for Chris’s thoughts and check out the whitepaper.

Leave a Comment

Understanding the Receiver Operating Characteristic Curve

Ken Koon Wong digs into ROC and the area under the curve (AUC):

We see ROC-AUC so often with classification models, we know the higher the better, but there is always that, well it depends scenario. I’ve always wanted to know what the pitfall is, how to avoid it, and how to do better. Let’s go from the basics on how to code ROC-AUC from scratch to decision curve analysis!

Click through to learn how to calculate ROC and dig into the topic a bit. H/T R-Bloggers.

Leave a Comment

Tracking SQL Server Login Failures

Ed Pollack builds some infrastructure:

Failed logins are one of the clearest early-warning signs of trouble on a SQL Server – whether that’s a misconfigured connection string, an expired password, or an actual unauthorized access attempt. Yet, by default, SQL Server won’t proactively tell you when they happen; you have to go looking.

This guide walks through how to pull login failure data using sys.xp_readerrorlog, filter it by time and error type, parse it into readable columns, aggregate repeat offenders, and automatically email a summary report — turning a passive log file into an active security and troubleshooting tool.

Click through for the process and scripts.

Leave a Comment

Decomposition Options Available in T-SQL

Jerry Nixon shares some options:

Application developers already know what happens when one method does everything: it becomes difficult to read, test, reason over, and safely change. We use patterns like decomposition, encapsulation, and explicit dependencies because they solve those problems.

T-SQL does not give us classes, inheritance, interfaces, or polymorphism in the same way C# does, but that does not mean good software practices stop applying when logic moves into the database.

Decomposition is a good example. Breaking complex database logic into sensible, well-defined components can reduce complexity, improve readability and maintainability, and make individual pieces easier to test. These are established, respected, and proven techniques for building great software, whether the code runs in an application or inside the database.

My problem is, there are performance costs to T-SQL decomposition. Unfortunately, Jerry doesn’t cover that at all in his post, but attempts at decomposing in SQL Server often fail for exactly that reason.

Leave a Comment

False Enrichment from a SIEM

Andreas Wolter takes a look at an alert:

This week, early morning, a customer alerted me that my account was possibly involved in an incident.

The alert came from Rapid7 InsightIDR:

Andreas has an example in which the SIEM decided that his user account was the relevant one, despite there being no logged in user. It’s an interesting story around how it’s critical to understand your sources and what they’re actually telling you.

Leave a Comment