Press "Enter" to skip to content

Curated SQL Posts

Sub-Transactions and PostgreSQL Performance

Shane Borden lays out an argument:

The short answer is always “maybe”. However, in the following post, I hope to demonstrate what creates a sub-transactions and what happens to the overall transaction id utilization when they are invoked. I will also show how performance is affected when there are lots of connections creating and consuming sub-transactions.

Click through for some testing and results.

Leave a Comment

Fixtures in Pytest

Jason Yousef shows off a capability in Pytest:

Pytest is one of those tools that feels obvious after you’ve used it for a bit. Tests are just functions. Assertions read like normal Python. And when you need context—database sessions, config, mock data—you reach for fixtures instead of duct tape.

Read on to see how they work. Admittedly, I don’t think I’ve used fixtures before in Pytest, but now seems like a good time to try it.

Leave a Comment

Coding against the Happy Path

Andy Brownsword thinks about successful code:

A common time to revisit old code is when something breaks. I was contemplating Pat’s question this week when a field length change had caused a truncation issue in an old SSIS data flow. Some code doesn’t age badly because it’s wrong, but because it didn’t expect to fail.

It’s all too easy to write a piece of code which ‘does the thing’, run a few variant tests, and send it on its way. But will it stand the test of time? That’s where my good and bad code diverge, and I usually revisit the code and find the old milk.

Admittedly, I’m not as good at this as I should be either. It can be a challenge to think through the possible issues that could arise and develop code to mitigate or eliminate those issues. But as Andy points out, it can be critical to success.

Leave a Comment

Starting an Expired SQL Server VM

Rob Douglas ran out the clock:

My preview trial of 2025 was evaluation version, and if you let that run past 180 days your SQL instance just will not start. I had an old Azure VM that I fired up to grab some code from a SQL Agent job I had been playing with and hit exactly this problem. Here’s the workaround:

Click through for the process. Fortunately, Rob doesn’t stop at how to get the instance up again, but continues into installing a non-evaluation version.

Leave a Comment

Being a Steward of Code

Louis Davidson shares a perspective:

So not only do I know how some of my code has aged, I am constantly reminded of it. I think of it in different ways:

  • How well the code was written in the first place
  • If it is still in use
  • If it can be/has been modified by someone else (or even you)

Some of this can be a challenge given external constraints, like needing to get it in production now-now-now! But I do like the way Louis thinks about the problem.

Leave a Comment

Preventing Legacy Code

Deborah Melkin shares some tips on preventing code from becoming “legacy code”:

This is an interesting question. In some ways, it’s hard to say how my code has aged. no one is yelling at me that my code is breaking production, so that’s a good sign. I have definitely talked about times where I wish I could go back and do something differently because it would have been a little bit smarter to do. I’m no longer at some of those companies and one of them doesn’t even exist in that incarnation anymore so I have no clue how that code is being used or if it even got fully implemented. I’ve done a lot of reviews of other people’s code and the most problematic legacy code was the code that would have been problematic at the time it was written but was good enough to get by.

Read on for a couple of broad tips that can help keep your code from becoming “legacy code” in the pejorative sense of the term.

Leave a Comment

Viewing Nested Lists in R with xfun::tabset()

Yihui Xie wants to document the contents of nested lists:

Complex nested lists in R can be difficult to explore and understand at a glance. The str() function is helpful for examining structure, but large nested lists can quickly become overwhelming.

While I was writing the documentation for tabsets in litedown, I almost laughed at myself for the support for nested tabsets, because I had no idea why anyone would want this feature. However, I suddenly realized that it can be a very useful tool for exploring nested lists in an interactive way, so I wrote a quick implementation: xfun::tabset().

Click through to see how it works.

Leave a Comment

Monitoring Query Plan Utilization in PostgreSQL

Ahmed Gouda shows how to use pgwatch to track query plan utilization:

The PostgreSQL ecosystem just introduced a new pg_stat_plans extension. It’s similar to pg_stat_statements but it tracks aggregated statistics for query plans instead of SQL statements.

It exposes a SQL interface to query those statistics via the pg_stat_plans view, and in this post, I will explore how easy it is to integrate such extensions with pgwatch for those who want to improve/customize the metrics gathered from a monitored database.

Click through for the demo.

Leave a Comment

The Final Month of Azure Data Studio

Rebecca Lewis plays a funeral dirge:

Azure Data Studio retires on February 28, 2026. No more updates, no more security patches, no more support. Microsoft announced this a year ago and has been pointing everyone toward VS Code with the MSSQL extension ever since.

Sounds straightforward. Install VS Code, add an extension, and carry on. Yet it is not really that simple, and it depends a lot on how you used ADS.

I appreciate that Rebecca has a table of functionality, including what is available right now and what is not yet ready. I remember trying the VS Code MSSQL extension early on and realizing just how much work they had to do, and it looks like they’ve done a good amount of that work. Running on Linux, I was always a proponent of Azure Data Studio, even when it was SQL Operations Studio and you had a messy bundle of files to install manually (I was one of the very early beta testers).

The good news is that I do believe the SQL Server tools team will continue development on this. The success of non-SSMS tools has been hit or miss, but having a multi-OS, developer-friendly way to interact with SQL Server is important.

Leave a Comment

DAX DATEADD Parameters and Calendar-Based Time Intelligence

Marco Russo and Alberto Ferrari check how two sets of functionality overlap:

The primary reason to adopt the new calendar-based time intelligence in Power BI is its flexibility. Classic time intelligence functions work out of the box and deliver meaningful results in most scenarios. However, to do so, they make assumptions about the calendar structure and the desired outcomes. Sometimes, the choices are not aligned with the user requirements, and developers need to author their own time intelligence calculations.

The new calendar-based time intelligence functions provide greater flexibility by allowing developers to configure parameters that drive the internal algorithms to meet diverse requirements. Using these parameters requires a precise understanding of the scenario for which they were built, which requires some attention to detail.

Click through to learn more.

Leave a Comment