Press "Enter" to skip to content

Curated SQL Posts

The Continuing Relevance of Blogs

Aaron Bertrand lays out an argument:

I read fewer technical blog posts than I used to. This is partly because I find information differently, and partly because I’m 30 years into this. My reading habits say more about where I am in my career than about the value of blogging.

I write fewer technical blog posts than I used to, too. This is mostly a function of time and juggling work and life priorities, rather than a lack of ideas or perceived value in sharing them.

I still value blogs as places to learn, share ideas, and express opinions.

Given my entire schtick of finding and linking to interesting blog posts, I am naturally inclined to agree with Aaron’s points.

Leave a Comment

Building a Type 2 SCD with dbt Snapshot

Koen Verbeeck creates a dimension:

An SCD Type 2 dimension preserves history by inserting a new record every time a tracked column changes, rather than overwriting the old value. Building one by hand usually means writing custom merge logic, but dbt’s built-in dbt snapshot feature can do this for you without any extra code.

This article picks up where my previous guide on loading a Type 1 slowly changing dimension with macros left off. This time, we’ll use dbt snapshots to build a full SCD Type 2 customer dimension in a Microsoft Fabric warehouse: from the underlying view, through the snapshot configuration, to the final dimension model.

Click through to see how.

Leave a Comment

The IsAvailableInMDX Flag in Power BI Semantic Models

Phil Seamark explains:

There is a property in Power BI semantic models you can set per column called IsAvailableInMDX. When most people discuss this property, the first question often asked is, “Are you using Excel to query the semantic model?”. If the answer is no, the usual follow up is “turn it off everywhere, you will save memory and your refresh will be faster”.

For Import models, turning it off can save memory by removing a supporting structure from a column. But a DAX query may have been making good use of that structure, particularly when filtering the column. Direct Lake is different: it uses its column dictionary for these DAX optimisations, but the setting still matters for Excel field availability.

Read on to learn whether your environment might benefit from this, as well as other considerations.

Leave a Comment

Reviewing the Always Encrypted Paper

Anna Hoffman continues a series on reviewing important academic papers in SQL Server’s history:

Encryption at rest solves one threat. It stops someone who walks off with the disk. It does nothing about someone with administrative access to the running server, because the database decrypts data into memory to do anything useful with it.

For a lot of workloads that gap doesn’t matter. For health records, financial data, or anything where the customer’s threat model includes the cloud operator, it matters a great deal.

Azure SQL Database Always Encrypted (SIGMOD 2020) describes how SQL Server runs real queries, including range comparisons and LIKE patterns, against data it never holds the keys to.

Read on for Anna’s thoughts about the paper, its claims at the time, and how Always Encrypted has changed (for the better) since the original paper.

Leave a Comment

Standing up Active Directory and a Windows Cluster

Dualcore DBA is doing some sysadmin work. First up is setting up a domain controller:

In this post, we’ll walk through the process of how I set up an Active Directory (AD) in my home lab. I know, this blog is normally database focused, so why are we looking at Active Directory? Well, yes, it isn’t strictly database related. However, where there is an enterprise SQL Server estate, there is normally Active Directory. In the next few posts, we’ll be looking at Availability Groups, which, whilst configurable without AD, generally are run in AD environments. Also, it isn’t really a great deal of work to set up in the home lab. It takes longer to install the Windows server than to actually set up AD, so it’s not really an issue to set it up to have a more realistic lab environment.

I am using Windows Server 2022 and have set up a specific VM for this purpose which is fairly modest with 2 CPU cores and 4GB of memory.

After that, try on creating a cluster without a domain setup:

This post documents the process of setting up a non-domain Windows Server Failover Cluster, officially known as a Workgroup Cluster. The process is similar to Setting Up a Windows Cluster, however there is a slight difference in this scenario which is that the nodes in the cluster are not part of an Active Directory domain. This process can be used to set up a SQL Server Availability Group where the nodes are not in an Active Directory environment.

And creating a cluster inside of a domain:

In this post, we’ll walk through setting up a Windows Server Failover Cluster (WSFC). This is a requirement of SQL Server Availability Groups, something which we’ll be using on this blog and so I will be setting one up that can be used in the home lab I use to write my blogs. A Windows Failover Cluster is a group of independent servers that work together, continuously monitoring each other, so that if one server fails or goes offline, another can automatically take over its workload with minimal interruption to users. WSFC handles the “which node should be primary and what do we do if it isn’t” on behalf of a SQL Server Availability Group.

Leave a Comment

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