Press "Enter" to skip to content

Curated SQL Posts

Just One Well-Placed Index

Eric Cobb has a success story:

This image is an actual screen shot of one of our production SQL Server’s CPU usage, taken from our SQL Sentry monitoring system. Obviously this server was under some strain. Users were complaining that queries were taking 30+ seconds to run when they normally returned data in milliseconds. It eventually reached a point to where applications were timing out because queries were taking so long. After doing some analysis in SQL Sentry, we were able to determine what was causing the CPU spike, and came up with 3 nonclustered indexes to add to help alleviate the pressure. The screen shot you see here is what happened after I added the first index.

Click through to see the image as well as the major difference in CPU utilization from a single change.

Comments closed

The Power BI Premium vs Azure Analysis Services Gap is Closing

Marco Russo has an update:

Almost 18 months ago I compared Azure Analysis Services and Power BI Premium for large datasets. At that time, Azure Analysis Services was a clear choice, but it is almost time to update that post with a longer article. Because of time constraints, I just want to quickly review what changed so far, promising a longer and more detailed update in a few months.

Read on to see Marco’s synopsis of what has happened since then. For my money, Power BI Premium Per User is already at a place where I’d prefer it to Azure Analysis Services.

Comments closed

When Bar Charts Don’t Start at Zero

Alex Velez has a confession:

Spoiler alert: I made a bar chart that does not have a zero baseline. I should add that this was intentional and not for teaching purposes, but rather because it seemed like the more appropriate solution for my given scenario.

This is an interesting edge case, but honestly, I think a bar chart is the wrong choice for the job here. I definitely prefer a dot plot here, even if the one Alex put together was a bit noisy. I think the best answer might have been to have a vertically aligned dot plot, similar to the final bar chart except without the bars. That reduces a lot of the noise while letting you label the specific points.

As far as the topic, I defer to noted philosopher Ron Swanson: “There’s only one thing I hate more than lying: skim milk. Which is water that’s lying about being milk.”

Comments closed

SQL Server: Side-By-Side Install or Direct Upgrade?

Kenneth Fisher lays out preferences between two upgrade paths:

Most discussions like this start with the fact that an in-place upgrade is far easier but riskier if anything goes wrong. Side-by-side is more work and you run the risk of forgetting something. But if something goes wrong you just move back to the old instance.

I thought about something that isn’t usually part of the discussion this week while working on a side-by-side migration.

Read on for Kenneth’s insight. My general preference is side-by-side updates on a new server, as that helps get rid of operating system bit rot as well.

Comments closed

A Review of Serverless SQL Pools

Teo Lachev lays out a review of serverless SQL pools in Azure Synapse Analytics:

Being able to query files using SQL is great. Some of you might remember the U-SQL language that was introduced a few years ago alongside Azure Data Lake Storage (ADLS) Gen 1 which is now deprecated. It never caught up because it looked like SQL but it wasn’t (it was actually closer to C#). Now we’re talking about real SQL. To query files! This opens the possibility to implement a logical warehouse (the emphasis is on logical as everyone to my knowledge who tried to replace a data warehouse with a data lake has failed). Or, you can connect Power BI to the serverless endpoint and start querying all these files in DirectQuery mode. So, this enables real-time BI on top of file extracts.

Click through for the pros and cons of using serverless SQL pools today.

Comments closed

Executing Azure Data Factory Pipelines with Power App

Rayis Imayev has a plan:

One of my university professors liked to tell us a quote, “The Sleep of Reason Produces Monsters”, in a way to help us, his students, to stay active in our thinking process. I’m not sure if Francisco Goya, had a similar aspiration when he was creating his artwork with the same name.

So, let me explain my reasons to create a solution to trigger Azure Data Factory (ADF) pipelines from a Power App and why it shouldn’t be considered as a monster 🙂

If that’s not an introduction enticing enough to get you to read the whole thing, I don’t know what is.

Comments closed

Data Type Conversions and Query Folding

Chris Webb explains how data type conversions and query folding might not mix:

It’s surprisingly easy to stop query folding happening in Power Query by changing the data type of a column. This is mentioned in the docs here, and it’s something several people have blogged about already (for example here). However there is something new to note: an option that will allow you to convert text columns to number or date columns in a foldable way for SQL Server data sources.

Consider the following table in a SQL Server database that consists of a single nvarchar(50) column containing numeric values:

Click through for the example, and also check out the comments below for more info.

Comments closed

Comparing Property-Based and Partition-Based Testing

Mark Seemann compares and contrasts two types of testing which typically get conflated:

To be fair, the overlap may easily be larger than the figure implies, but you can certainly describes properties without having to partition a function’s domain.

In fact, the canonical example of property-based testing (that reversing a list twice yields the original list: reverse (reverse xs) == xs) does not rely on partitioning. It works for all finite lists.

You may think that this is only because the case is so simple, but that’s not the case. You can also avoid partitioning on the slightly more complex problem presented by the Diamond kata. In fact, the domain for that problem is so small that you don’t need a property-based framework.

This is an interesting look at two related but separate branches of testing.

Comments closed

Finding Eager Index Spools

Erik Darling hunts the most dangerous prey of all:

I’ve written a bunch about Eager Index Spools, and how to fix them, but I’ve always sort of left the “finding” part up to you, or pointed curious tuners to tools like sp_BlitzCache.

Recently though, I worked with a client who had Eager Index Spools so frequently that we needed to track them down specifically.

This is the plan cache query that I used to do it — they didn’t have Query Store enabled — and I wanted to share it.

Click through for the query.

Comments closed