SQL Server Performance Tuning

How We Made T-SQL Queries 4 Times Faster

Updated October 29, 20252 min read

Improvement after tuning

4xDURATION
5xCPU
48xDISK

Reading from disk is the slowest operation SQL Server does.

Therefore, tuning for less disk “reads” is often the target.

Problem

The stored procedure showed up in the top resource-consuming report. It was putting too much stress on the CPU.

Resource consuming report

Pre-tuning Metrics

142
Duration (ms)
157
CPU (ms)
12,805
Disk (number of reads)

Solution

To fix this issue, we added two new indexes.

Two new indexes added to SP

Before vs. After

The improvement was significant: the total number of disk reads decreased to just 266 from 12,805, resulting in a 5x reduction in CPU time!

Before and after adding indexes

CPU (ms)

157
Before tuning
31
After tuning
BeforeAfterImprovement (x)
Duration (ms)*14232~4x (or 444%)
CPU (ms)*15731~5x (or 444%)
Disk (number of reads)*12,805266~48x (or 4,814%)
*The numbers are an average of multiple T-SQL runs

Overall, we observed a staggering improvement, making the query execution 4 times faster!

Why does disk improvement matter for stored procedure speed?

It’s simple. The less you access the disk, the more disk capacity is left over.

It works just like a highway. Imagine a 3-lane highway with just 5 cars driving on it every minute.

What if you add 50 cars? The speed remains the same because 55 cars don’t overload that highway.

What if you add another 500 or 5000? Now you are starting a slowdown in traffic.

They all still get home. But not at the same speed anymore.

It's the same deal with SQL Servers. That's why it's crucial to speed-tune the most critical resources.

The fewer hits to the storage, the more capacity available.

In this tuning session, better performance was achieved by overhauling a stored procedure and adding two new indexes.

As a result - 4 times faster query!

Discover More

Discover what clients are saying about Red9

Red9 has incredible expertise both in SQL migration and performance tuning.

The single biggest benefit has been performance gains and tuning associated with migrating to AWS and a newer version of SQL Server with Always On clustering. Red9 was an integral part of this process.… The deep level of knowledge of MSSQL is incredible and the combined experience and expertise has been a huge asset.… Red9 was able to find a number of inefficient indexes and performance bottlenecks that resulted in over 400% improvement in latency.

Rich StaatsRich StaatsCloud EngineerMetalToad
See more testimonials