SQL Server Performance Tuning

How We Made T-SQL Queries Run 3x Faster

Updated
2 min read
Written by
Mark Varnas

Improvement after tuning

3x

DURATION

3x

CPU

11x

DISK

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,462

BEFORE

918

AFTER

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.

Article by
Mark Varnas
Founder | CEO | SQL Veteran
Hey, I'm Mark, one of the guys behind Red9. I make a living performance tuning SQL Servers and making them more stable.

Managed SQL Server services, consulting, and emergency support from expert DBAs to improve performance, predictability, and cost.

Get started with Red9 today.

Contact us

Discover More

SQL Server Health Check SQL Server Migrations & Upgrades SQL Server Performance Tuning SQL Server Security SQL Server Tips

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 Staats 5 stars
Rich Staats
Cloud Engineer
MetalToad

Always willing to go an extra mile

Working with Red9 DBAs has been a pleasure. They are great team players and have an expert knowledge of SQL Server database administration. And are always willing to go the extra mile to get the project done.
5 stars
Evelyn A.
Sr. Database Administrator

Boosts server health and efficiency for enhanced customer satisfaction

Since adding Red9 to the reporting and DataWarehousing team, Red9 has done a good job coming up to speed on our environments and helping ensure we continue to meet our customer's needs. Red9 has taken ownership of our servers ensuring they remain healthy by monitoring and tuning inefficient queries.
5 stars
Andrew F.
Datawarehousing Manager
See more testimonials