Live registration reopens October 1, 2026, in 5d 20h 17m — Notify me
Performance Tuning

Query Exercise: Why Are These 3 Estimates So Wrong?

Our prior Query Exercise introduced SQL Server's 201 buckets problem: its inability to accurately estimate rows for more than 201 outliers in a table. I followed up with a solution using filtered statistics to help with the next 200 outliers, and I talked about how that's really overkill for the simple problem we were facing in that initial challenge.

Read more about Query Exercise: Why Are These 3 Estimates So Wrong? 6 comments — Join the discussion
Performance Tuning

Query Exercise Answers: Solving the 201 Buckets Problem

In this week's Query Exercise challenge, I explained SQL Server's 201 buckets problem. SQL Server's statistics only handle up to ~201 outliers, which means that outliers ~202-300 get wildly inaccurate estimates.

In our example, I had an index on Location and perfectly accurate statistics, but even still, this query gets bad estimates because Lithuania is in outliers ~202-300:

Read more about Query Exercise Answers: Solving the 201 Buckets Problem 8 comments — Join the discussion

About Half Of You Don’t Have Your Databases Under Control.

I ran a poll over on LinkedIn to find out if people have 100% of their databases under some kind of source control or version control.

I broke the answers up into two sets, developers and non-developers, because I had a hunch that the developers' answers would be very different than the rest, and indeed they were:

Read more about About Half Of You Don’t Have Your Databases Under Control. 10 comments — Join the discussion
Performance Tuning

Query Exercise: Solving The 201 Buckets Problem

When you run a query, SQL Server needs to estimate the number of matching rows it'll find - so that it can decide which indexes to use, whether to go parallel, how much memory to grant, and more.

For example, take any Stack Overflow database, and let's say I have an index on Location, and I want to find the top-ranking users in Lithuania:

Read more about Query Exercise: Solving The 201 Buckets Problem 14 comments — Join the discussion
Performance Tuning

Query Exercise Answer: What Makes SELECT TOP 1 or SELECT MAX Different?

This Query Exercise was very different: I didn't ask you to solve a particular problem. I pointed out that I've heard advice that SELECT MAX is faster than SELECT TOP 1, and that's not quite true. I asked you to find factors that would cause these two queries to get different execution plans: [crayon-6ab5edb3888bf553782388/] In the…

Read more about Query Exercise Answer: What Makes SELECT TOP 1 or SELECT MAX Different? 4 comments — Join the discussion

SQL ConstantCare® Population Report: Summer 2024 (And Upcoming Gamification Badges)

The short story: SQL Server 2022 finally saw some growth this quarter! Two years after the release, 1 in 10 SQL Servers is finally running the latest version.

The long story: ever wonder how fast people are adopting new versions of SQL Server, or what’s “normal” out there for SQL Server adoption rates? Let’s find out in the summer 2024 version of our SQL ConstantCare® population report.

Read more about SQL ConstantCare® Population Report: Summer 2024 (And Upcoming Gamification Badges) 13 comments — Join the discussion

[Video] I Must Be an Idiot: Automatic Tuning Never Works for Me.

I don't get it. I've given this feature one chance after another, and every time, it takes a smoke break rather than showing up for work.

The latest instance involved the recent Query Exercise where you were challenged to fix a computed column's performance. In the comments, some folks noted that performance of the query was actually great on old compat levels, like SQL Server 2008, and that it only sucked on newer compat levels like 2016 and later.

Read more about [Video] I Must Be an Idiot: Automatic Tuning Never Works for Me. 21 comments — Join the discussion

Thoughts About Stack Overflow’s Annual Developer Survey

Every year, Stack Overflow runs a developer survey about technology, work, community, and more. This year's results include 65,437 responses from developers around the world. The results are biased towards the kinds of developers who use Stack Overflow - 76% of the respondents reported that they have a Stack Overflow account. I would guess that…

Read more about Thoughts About Stack Overflow’s Annual Developer Survey 7 comments — Join the discussion