SQL Server Performance Tuning

How We Made T-SQL Queries 3 Times Faster

Updated October 29, 20251 min read

Written byMark Varnas

Improvement after tuning

3xDURATION
3xCPU
11xDISK

Reading from disk is the slowest operation SQL Server does.

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

Problem

The frequently executed stored procedure select_scInvoicesCredits is performing slower than expected.

Pre-tuning Metrics

2,464
Duration (ms)
2,469
CPU (ms)
118,566
Disk (number of reads)

Solution

To fix the issue we added additional index IX to tblRcptitem.

Before vs. After

The improvement was huge: the total number of disk reads was 10,785 instead of 118,566!

Pre-tuning Metrics

118,566
Before tuning
10,785
After tuning

Below is the detailed breakdown by metric:

Before After Improvement
Duration (ms)*2,462918~3 ( or 268%)
CPU (ms)*2,469922~3 ( or 268%)
Disk (number of reads)*118,56610,785~11 ( or 1099%)
*The numbers are an average of multiple T-SQL runs

After our tuning, the stored procedure became significantly faster, showing an overall improvement of 268%!

That’s almost 3x faster!

Duration (ms)

2,462BEFORE
918AFTER

Final thoughts

Adding indexes can really speed up your SQL Server queries, but there's a catch - they might also slow things down if not used wisely.

In today's case, an additional index helped us slash the overall duration of the stored procedure by nearly 3x - an outstanding outcome!

But it’s very important to understand your overall workload and find a good balance between making your queries efficient and not paying too much for that.

Discover More

Discover what clients are saying about Red9

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

The 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 integral to this process. The deep knowledge of MSSQL and combined experience of Red9 have been a huge asset during a difficult migration. Red9 found inefficient indexes and performance bottlenecks that improved latency by over 400%.

Rich StaatsRich StaatsCloud EngineerMetalToad
See more testimonials