Indexing and Statistics

Designing, evaluating, maintaining, and troubleshooting indexes and statistics.

568 associated posts270 primary posts

T-SQL & Development

Update: SQL Server 2025’s REGEX Performance Isn’t So Bad!

Back in March 2025 when Microsoft first announced that REGEX support was coming to SQL Server 2025 and Azure SQL DB, I gave it a quick test, and the performance was horrific. It was bad in 3 different ways:

The CPU usage was terrible, burning 60 seconds of CPU time to check a few million rows
It refused to use an index
The cardinality estimation was terrible, hard-coded to 30% of the table

Read more about Update: SQL Server 2025’s REGEX Performance Isn’t So Bad! 14 comments — Join the discussion

How to Query JSON Data Quickly in SQL Server, Part 2: SQL Server 2025

SQL Server 2025 and .NET 10 bring several new improvements to storing JSON natively in the database and querying it quickly. On the SQL Server 2025 side, the two big ones are the new native JSON indexes and the new JSON_CONTAINS function. Let's see their improvements in action. On the .NET 10 side, EF 10…

Read more about How to Query JSON Data Quickly in SQL Server, Part 2: SQL Server 2025 11 comments — Join the discussion
Performance Tuning

How to Query JSON Data Quickly in SQL Server, Part 1: Pre-2025

Before SQL Server 2025, if you want to store JSON data in Microsoft SQL Server or Azure SQL DB, and you want fast queries, the easiest way is to:

Store the data in an NVARCHAR(MAX) column (because the native JSON datatype didn't arrive until SQL Server 2025)
Add a computed column for the specific JSON keys we'll want to query quickly
Index those keys
Query it using the JSON_VALUE function

Read more about How to Query JSON Data Quickly in SQL Server, Part 1: Pre-2025 12 comments — Join the discussion

[Video] Office Hours on the Beach in Cancun

In retrospect, I should have put on sunscreen - even for just a 20-minute Office Hours session on the beach! Dang, that sun is powerful. Let's go through your top-voted questions from https://pollgab.com/room/brento. This is a 360-degree video, so if you watch it on YouTube, you'll be able to pan the camera around and take a little virtual vacation with me.

Read more about [Video] Office Hours on the Beach in Cancun 4 comments — Join the discussion
Performance Tuning

SQL Server 2022 Finally Fixed a SQL Server 2008 Query Plan Bug!

For yeeeeeears, when I've explained execution plans, part of my explanation has included the instructions, "Read the plan from right to left, top to bottom, looking for the place where the estimates vs actuals are suddenly way off." Here's an example:

Things seem to be going okay on the query plan until you hit the key lookup, which brought back 13 rows of an estimated 19,452. That would appear to be a pretty doggone bad estimate.

Read more about SQL Server 2022 Finally Fixed a SQL Server 2008 Query Plan Bug! 5 comments — Join the discussion