Press "Enter" to skip to content

Curated SQL Posts

Running Postgres in Docker

Grant Fritchey spins up a container:

The goal of this guide is simple: get PostgreSQL up and running in the fastest, easiest way. You’ll then learn how to create databases in PostgreSQL and the objects that live within them.

The two easiest ways to get started working in PostgreSQL are to either use containers, or create an account with a cloud provider. In this case, we’ll be using containers.

This post covers a lot of the basics of pulling a Docker container image and how you interact with that running Postgres container.

Leave a Comment

Page Splits and Fill Factor

Brent Ozar differentiates page splits:

You’re looking at page split numbers in a monitoring tool or Perfmon, and you’ve heard that page splits are bad, so you’re lowering fill factor, expecting your page splits to go down.

You’re monitoring the wrong number.

Jeff Moden has a good comment in there as well that what Brent’s saying is often true, but there can be edge cases. Though that’s part of the point: it’s an edge case, not a primary case. And I like Erik Darling’s comment on the post as well, as it’s often fretting about the color of the furniture when the house is burning down.

Leave a Comment

Using the Azure Resiliency Agent

Reitse Eskens gives a copilot a spin:

And that isn’t limited to services like storage, web portals, user management, and data stuff. It’s also location, backups, and disaster recovery. But there’s a catch: you need to make sure this is configured. I always compare the cloud (Azure in my daily work) with a huge box of Lego. You have all the pieces and elements to make something cool, but you have to build it. Even when you automate it, you still need to think about what you want.

Now, before I continue my Azure Fundamentals training, let’s move on to what this post is about: resiliency. Or, how your environment is set up for disaster recovery.

Let’s use the Azure Copilot to guide the process, create the necessary resource and review the advice.

Click through to see how it works. Because it’s in preview right now, we don’t know how much it will cost later. But in the meantime, you can give it a try.

Leave a Comment

Storage Engines in MySQL versus MariaDB

Lukas Vileikis compares storage engines:

The big difference between MySQL and MariaDB largely revolves around database storage engines and anything related to them. In this article, I’ll walk you through some of the key differences between storage engines in MySQL and MariaDB, explain which is best for your use case, and detail how to change your database’s storage engine if necessary. 

Most of you will do just fine with InnoDB on either of the database management systems – however, those of you who are building something more wild and exotic might want to look specifically into MariaDB. 

Read on to learn more.

Leave a Comment

Building Daily Averages in DAX

Marco Russo and Alberto Ferrari take generative AI tooling for a spin:

Computing an average daily sales amount is straightforward: you should iterate over the dates, compute sales for each day, and average the results. An AI assistant can generate DAX code that works in just a few seconds; whether it computes the number you need is a different question.

In this article, we ask AI to generate every measure, function, and validation query. We start with a simple average and test it against more demanding scenarios. Our job is to explain the business requirements, challenge the proposed code, and verify the results. Each test reveals a missing detail from the original request.

The prompts below show a conversation with an AI agent. They describe how to get the DAX code from the AI. They are not a verbatim transcript: a different agent might produce different expressions.

This shows the duality of generative AI outcomes: you can end up with a good solution, but unless you know the ins and outs of what you’re doing, you can end up in a sub-optimal situation.

Leave a Comment

Fetching Query Plans in Fabric Data Warehouse

Louis Davidson shows a process:

So in this next entry in this series, I want to start to cover a topic that every nerdy SQL programmer is going to want to know. “How do I make a query faster?” If you have worked with relational databases, you know the simple answer is to… check the estimated query plan, run the query and look at the actual plan, and in many cases to be completely honest, add indexes.

Click through to see how closely your current SQL Server skills translate in this instance. The specifics of query tuning and table design in the Fabric Data Warehouse will differ a bit from on-premises SQL Server, but at this level, it’s quite similar.

Leave a Comment

An Explanation of Fabric Licensing

Paul Turley digs in:

When the Power BI cloud service morphed into the Fabric platform a few years ago, Microsoft introduced very attractive cost and capacity options for small organizations, teams and projects – and its easy to scale-up. This is why Fabric works for both small and huge workloads.

Fabric licensing might look intimidating from the outside, mostly because Microsoft describes it in acronyms. Strip those away and it really boils down to two questions.

Click through for those questions and what it all means.

Leave a Comment

A Decade of Logical Replication in Postgres

Dimitri Fontaine reflects on ten years of functionality:

A long time ago I ran a write-heavy system on a hub and a handful of workers. Each worker took a share of the application traffic and wrote events locally. The hub owned the reference data (customers, plans, prices), pushed it down to the workers, and pulled every worker’s events back up to compute the invoices. The plumbing was Londiste and PgQ: triggers on every table, a queue per node, a ticker, and a Python daemon per hop. It worked, and it was a lot of moving parts to explain to anyone new.

Postgres 10 shipped logical replication in 2017, and 19 is the tenth release that has it. Every release since Postgres 10 has taken a piece of that plumbing and made it a line of SQL.

Click through for a reflection on what’s there and what has changed over the years. This first post in the series covers the hub and worker model.

Leave a Comment

Creating Alerts in Microsoft Fabric

Koen Verbeeck turns on the Bat-signal:

We are building a new data platform with Microsoft Fabric and we’re using the warehouse for our “gold layer”. We don’t have real-time ingestion or analytic requirements, but we have a use case where we want to send an alert if a certain threshold is reached. Ideally, the alert is sent when a SQL query returns a result set.

Click through to see how that’s possible, as well as what kinds of rules, triggers, and conditions you can set.

Leave a Comment

Creating a Security Checklist Based on STIGs

Marlon Ribunal builds a checklist:


Here’s a follow up for our US Department of Defense STIG document. In my previous post, SQL Server Security Hardening Guide Using the DoD STIG Checklist, I walked through how I used the DoD STIG checklist as a starting point for reviewing and hardening a SQL Server environment.

After going through the checklist, I started thinking about what I would actually want to use the next time I perform a security review.

The DoD STIG for SQL Server is a great, solid starting point for establishing your security practices with SQL Server. In fact, it’s also a good template for your own STIG in your organization. So, you may want to create a custom checklist that makes sense from the perspective of your SQL Server environment.

The STIG is detailed, which is a good thing, but I found myself wanting something a little more practical for day-to-day DBA work. Something I could open, work through one item at a time, record what I found, and come back to later without having to navigate through the entire STIG document every time.

Click through to see what Marlon came up with.

Leave a Comment