Press "Enter" to skip to content

Curated SQL Posts

DOP and Tipping Points

Erik Darling gets caught DOPing:

Erik Darling here with Darling Data. And I’ve got a question that I thought was interesting enough to actually answer with a brief demonstration, so I’m going to do that today. But it is about DOP and tipping points, or as I will lovingly refer to them from now on, DOPing points, because why not?

This video is more conjectural in nature and shows an interesting use of MAXDOP(1) to nudge the optimizer toward seeks rather than scans given a certain style of query.

Leave a Comment

Thoughts on Automatic Index Compaction

Monica Morehouse asks a question:

hile attending SQLCon and FabCon Europe in Barcelona, there were a lot of announcements that caught my attention. But there was one during the SQL keynote that made my DBA ears perk up: Automatic Index Compaction is generally available. And then came the comment that really got my attention: Could this be the beginning of the end of traditional index maintenance? Wait…WHAT? For those of us who have been working with SQL Server for a long time, index maintenance has practically been part of the DBA job description. Check fragmentation. Reorganize. Rebuild. Repeat. And for far too many environments, the strategy has basically been:

It’s Sunday at 2:00 AM. Time to rebuild ALL THE THINGS!

But should we really be doing that?

Click through for her answer. Also, shout out to Greg Moore in the comments for the Betteridge’s Law of Headlines usage. Greg is clearly a classy individual full of great ideas. Jeff Moden, additionally, has a comment worth reading.

Leave a Comment

Installing SQL Server and Creating a Cluster on a Linux VM Host

Lee Markup continues a series on building a SQL Server and Windows network on top of a Linux host:

All four VMs run on KVM/libvirt, using the SQLLab virtual network and subdomain.example.com we set up.

In this post, we will walk through an automated install of SQL Server and creating the Windows cluster needed to build an Availability Group.

Lee does not simply click next-next-next for installation.

Leave a Comment

Reseeding a Single Database in an Availability Group

John Morehouse solves a problem:

Recently, I found myself dealing with an Availability Group (AG) where I needed to remove a single database from one secondary replica and then add it back. Nothing particularly unusual about that, right? Except I wanted to use automatic seeding to rebuild that database without affecting the other databases already synchronized on the replica. That led me down an interesting rabbit hole involving how SQL Server handles automatic seeding, what happens when you remove a secondary database from an AG, and how you can rebuild just one database without disrupting the others.

Let’s take a look!

Read on to see how you can do this without disrupting the existing databases that are in good shape.

Leave a Comment

Choosing an Initial Fabric Capacity

Paul Turley drags the slider:

Picking your first Fabric capacity is basically a bet on how fast your usage will grow, and most people bet wrong in one particular direction: too big, too soon.

Match size to purpose, not ambition. An F2 or F4 is plenty for a pilot or a single developer testing pipelines and reports. A departmental rollout usually lands in the F8–F32 range, while an enterprise-wide deployment needs F64 or larger. Buying big before you know your real usage just funds idle capacity. It’s tempting to buy for the org chart you’ll have in two years, but Fabric makes scaling up trivial later, so there’s little upside in paying for headroom you’re not using yet.

Read on for some additional thoughts about what makes an F64 special and how you can save a bit of scratch.

Leave a Comment

A Simple Simulation of Simpson’s Paradox

Zhenguo Zhang demonstrates a principle:

Simpson’s paradox occurs when the direction of an association reverses after data from several groups are combined. For example, A can have a higher success rate than B in every subgroup, yet a lower success rate overall.

In this post, we will simulate exam outcomes in Python, examine the reversal using logistic regression and a plotnine figure, and explain why it happens. All Python code is embedded in this R Markdown document and runs through reticulate.

Click through for the code and demonstration.

Leave a Comment

From SAS to R

Gigi Kenneth continues a series:

If you’re moving regulated analysis from SAS to R, two things are worth knowing up front. R is a choice you can defend: regulators don’t tell you which software to use, and R has already been through FDA review in public pilot submissions. And the language itself is the cheap part. Most of the cost and risk comes from six other places, and most of those are about planning, not programming.

Part one asked whether SAS is still worth keeping. This post covers why R, and where to put your budget and attention once you commit.

Click through for several notes that may trip up a migration, particularly in a clinical environment.

Leave a Comment

Writing MICE from Scratch in R

Ken Koon Wong rewrites a package:

We used mulitple imputation by chained equations (MICE) quite often in imputing missing data in many occasion, but I never really understood the mechanism behind it except that it appears magical! 🧙 I want to see if I can build this from scratch as a mean to understand the foundation of MICE so that at least it will give me the illusion of understanding. 🤣 Join me in my messy journey of trying to code it from the ground up (FYI, I’m not coding OLS or MLE from the ground up…), and let’s see if we can create some “magic” here! This is going to be a bumpy one with lots of coding, and maybe less of mathematical formulae. I’ll try my best to provide a TL;DR for each section so that we can get a high level view as well. Buckle up! And oh, Happy Halloween! 🎃 What a better time to look at magical recipes of statistics! Let’s go!

I really like this post. The end result isn’t exactly what the mice implementation gives, but it’s close enough to show real understanding of the algorithm. H/T R-Bloggers.

Leave a Comment

Testing AI Agent Skills

Eugene Meidinger and Ruben Van de Voorde try things out:

Writing a skill takes time, and skills are context that can help but also hurt the quality of the agent’s work. So how do you know if a skill actually helps? You can test it with evals. An eval is a prompt that you re-run under the same conditions, so that the only variable is what you deliberately change. You use the same model, starting context, and the same files (and wipe leftover memory from previous attempts). Then you compare: before and after an edit, with and without a skill, or two versions of a skill. Agents are non-deterministic, so you have to run the comparison multiple times to get a reliable difference; a few runs per condition is enough to start. Decide how a run is scored before looking at the results: use objective checks where you can (did it run the right command?), and for subjective calls write down beforehand what a good answer must include. Also run in a clean workspace: if the solution is already in another branch, the baseline run isn’t a real test. Some companies run large automated eval suites, but a few saved prompts and some notes are enough to start.

Click through for a testing technique and a warning around relying on a generative model to do the work for you.

Leave a Comment

Fabric Capacity Units and F-SKUs

Paul Turley provides an explanation:

If there’s one concept that trips up nearly everyone moving into Fabric, it’s capacity units — because a CU isn’t what most people assume it is.

It’s compute, not seats.

A Capacity Unit has nothing to do with user counts or license tiers. It measures compute power, consumed in CU seconds as work actually runs. A report rendering, a pipeline moving data, a notebook chewing through a dataframe — all of it draws from the same shared pool of CU seconds on your capacity. Think of it less like a parking pass and more like a utility meter — it just keeps ticking based on what’s actually being computed, no matter who’s asking for it.

Read on for more information around CUs, as well as what F-SKUs provide and when you might want either.

Leave a Comment