When to stop tuning a query

In this session, you will see me tuning a very simple but surprisingly slow Transact-SQL query. You'll see different tuning techniques and the challenges associated with them. I will walk you through how to tune it and how to decide when to stop.

At the beginning, I will apply several query hints to overrule some optimizer decisions to mitigate the performance issue.

I will then rewrite the query and use tricks to lead the optimizer to better estimations and plan decisions. Additionally, you'll see how upgrading to SQL Server 2019 breaks this workaround.

Finally, I will provide reasons why SQL Server initially decided to use an improper execution plan for this simple query and fix the root cause. Here, it will be highlighted the difference between workarounds with hints and optimizer tricks, and proper solutions based on root cause elimination.

Feedback link:

Starts: 17:10 11th Mar 2022
Ends: 18:00 11th Mar 2022


Short Description
- In this session, I will walk you through how to tune a very simple but surprisingly slow Transact-SQL query and how to decide when to stop this process.

Slidedeck Link



Milos Radivojevic


On PremisesOperational DatabasesDevelopingOptimisingDatabase EngineSQL 2019AdvancedHow

The SQL Bits Story

SQLBits was formed in 2007 by a group of volunteers who were passionate about the SQL Server product suite and wanted to provide much-needed community-driven education to the data community.

As one of the largest data platform conferences in the world, we offer more opportunities to a wider audience.

15 Years

We’ve grown and expanded a lot since 2007.

2500 Participants

SQLBits is the best place to meet fellow data professionals.

82 Countries

We welcome data professionals from all over the globe.

1140 recorded sessions

All the live sessions are recorded and offered for free, year round.

Experience the SQLBits Conference


Want to be part of the SQLBits community?

Attend the London conference in-person or virtually on 

March 8-12, 2022 at ExCel London, UK.