Press "Enter" to skip to content

Curated SQL Posts

Reviewing the Power BI Date Picker

Teo Lachev takes a look at a new preview:

The June release of Power BI Desktop includes a preview of a new Power BI slicer configuration – Date Picker. It’s meant to solve two issues with report design.

Read on to see what those two issues are and how this new date picker can resolve them. It’s still in preview, so you’d have to change the settings in Power BI Desktop. And I imagine it won’t be available in Power BI Report Server because those people (including me) can’t be trusted to have nice things.

Leave a Comment

Using REMOVEFILTERS in DAX UDFs

Marco Russo and Alberto Ferrari make use of REMOVEFILTERS:

A DAX user-defined function, also known as a UDF, is expected to return a scalar or a table. However, because functions are fundamentally macro-expansion of DAX code, it is possible to return CALCULATE modifiers if the function is to be called only as a filter argument of CALCULATE.

To show a practical example of when the feature proves to be useful, we debug a measure that fails because some calendar filters are not being removed correctly. Fixing the measure elegantly requires creating a function that removes filters rather than returning a value.

Click through for that example.

Leave a Comment

Controlling Memory Grants in SQL Server

Erik Darling has a new video:

So we’ve got this query here that I have pre-run because it takes a little bit to run. And I don’t want to stand here in the hot, light heat while I wait for all this. This query will ask for quite a big memory grant, both because it is written in a way with this derived join, which will force us to run this query and produce a result.

And two, because we are selecting all of the columns from the comments table, one of them being a column called text, which is in InvarCar 700. So just to sort of get ahead of things a little bit, this query asks for an 11 gig memory grant. If you want to fix a big memory grant, you have three basic things you can do for any given query.

Click through to learn what you can do.

Leave a Comment

Master Database Compatibility Level

Jeff Iannucci explains an issue:

We were attempting to install a troubleshooting stored procedure in the master database of a SQL Server 2016 instance when we received the following error.

Msg 195, Level 15, State 10, Procedure sp_ShootTheTrouble, Line 227 [Batch Start Line 7]

‘TRY_CONVERT’ is not a recognized built-in function name.

This was unexpected, as TRY_CONVERT has been a command since SQL Server 2012. As a consequence, we were unable to install the stored procedure.

Tracking system database compatibility levels is a minor chore but an important one after an upgrade.

Leave a Comment

TheseusPlot 0.3.0 Released

Koji Makiyama announces an update to an R package:

TheseusPlot is an R package that decomposes differences in a rate metric between two groups into subgroup-level contributions and visualizes the results as a “Theseus Plot”.

For example, when a click-through rate, conversion rate, or retention rate differs between two time periods or groups, TheseusPlot helps answer questions such as: which subgroup contributed most to the difference?

I love the name and I think the plot concept is interesting, especially in the e-commerce context that Koji describes. H/T R-Bloggers.

Leave a Comment

Downtime Woes and Microsoft Fabric

Joey D’Antoni describes a problem:

All that being said, customers buy online services and expect them to be available. One of the reasons a company chooses Fabric, Databricks, or Snowflake is the notion that those platforms for Spark and various data warehousing options will be secured, patched, and better maintained than a non-technology company could do by simply deploying Spark into Kubernetes or VMware. With that, the cloud providers have an obligation to deliver services to their customers, and deliver availability and performance congruent with their pricing.

One of the things I expect from a cloud provider is honest post-mortems when they have an outage, and maintaining a history of their outages. These histories help architects better design systems, as we can better identify weaknesses in various cloud services that we might want to design around. Azure and AWS both do an excellent job of providing detailed information around “what happened” in incidents.

But as Joey mentions, Microsoft Fabric doesn’t have the same information. It also doesn’t have a dedicated SLA. But it does have a series of outages over the past month.

Leave a Comment

Tables without Histograms

Guy Glantser goes looking for stats:

A few weeks ago, I published a blog post titled “When Statistics Stay Empty Forever: A Hidden Edge Case with Empty Tables”

In that post, I described a scenario where statistics are created on an empty table, resulting in a statistics object without a histogram. If AUTO_UPDATE_STATISTICS is disabled and your maintenance solution doesn’t explicitly update statistics whose modification_counter is NULL, those statistics may never get a histogram – even after the table grows to millions or billions of rows.

Recently, I ran into another case involving missing histograms.

In this case, Guy found a table with 7 million rows and no histograms. Click through to see how that’s possible.

Leave a Comment

To Shrink, First You Must Grow

Eitan Blumin gives us a riddle:

Ever ran DBCC SHRINKFILE, watched it finish without a single error… and then discovered that your file is exactly the same size as before? You run it again. Same thing. And again. Nothing. Meanwhile you know there are gigabytes of empty space in there, taunting you. Welcome to one of the most maddening little corners of SQL Server.

Read on to understand why this happens and what you can do to fix it.

Leave a Comment