SQL Server Performance Tuning

How Two Indexes Made a CPU-Heavy Procedure 4x Faster

Updated October 29, 20252 min read

Capacity freed

80%less CPU per run

It was one of the top resource consumers on the server. Two indexes cut the average run from 142 ms to 32 ms.

CPU per run

Before157 ms
After31 ms

Source: average of multiple runs.

Reading from disk is the slowest operation SQL Server does.

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

The problem

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

Resource consuming report

The fix

To fix this issue, we added two new indexes.

Two new indexes added to SP

Why does disk improvement matter for stored procedure speed?

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 5,000? 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 important 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 adding two new indexes.

Under the hood

Before and after, every measurement

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
BeforeAfterImprovement
Duration (ms)*14232~4x
CPU (ms)*15731~5x
Disk (number of reads)*12,805266~48x
*The numbers are an average of multiple T-SQL runs

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

As a result - 4 times faster query!

Check Red9's SQL Server Services

SQL Server Consulting

Perfect for one-time projects like SQL migrations or upgrades, and short-term fixes such as performance issues or SQL remediation.

Discover More ➜

SQL Server Managed Services

Continuous SQL support, proactive monitoring, and expert DBA help with one predictable monthly fee.

Discover More ➜

Emergency SQL Support

Take the stress out of emergencies with immediate access to a SQL Server Sr. DBA 24x7x365

Discover More ➜

Explore All Services ➜