SQL Server Performance Tuning

How We Boosted SQL Performance by 40x

Updated October 29, 20253 min read

User experience

~5.6 GBless data read on every call

Every call made the app wait 40 to 60 seconds, long enough to time out. Now it returns the same results in under a second.

Data read per call

Before5,629 MB (5.6 GB)
After0.7 MB

Source: average of multiple runs. Data read = logical reads × 8 KB pages (687,157 → 90).

Reading from disk is the slowest operation SQL Server does.

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

The problem

spItemsDelivered stored procedure took 40 to 60 seconds (40,000–60,000 ms) to execute, causing app timeouts.

It was overdoing it with index scans, leading to excessive disk read operations.

The fix

  • Change: We've revised certain sections of the stored procedure.
  • Testing: We used the same test value for both old and new SP. The result set was identical, but the data row ordering was different.
  • Next steps: It is important to ensure that differences in data order will not lead to issues before implementing the change.

Final thoughts

This case illustrates that tuning can't always be perfected.

We aim to adjust the database code to avoid other changes.

Sometimes, even with an identical result set, rows may return in a different order, potentially disrupting the app.

It's essential to collaborate with the client application team to confirm that a different row order won't cause issues.

Under the hood

Before and after, every measurement

We cut the number of logical reads from 687,157 to just 90.

No joke!

Below is a detailed breakdown.

Before:

  • Table ‘tblDlvheader’. Scan count 9, logical reads 28,911, physical reads 0
  • Table ‘tblDlvitem’. Scan count 9, logical reads 363,865, physical reads 0
  • Table ‘tblOrderRows’. Scan count 9, logical reads 294,381, physical reads 0

After:

  • Table ‘tblDlvheader’. Scan count 5, logical reads 27, physical reads 0
  • Table ‘tblDlvitem’. Scan count 1, logical reads 27, physical reads 0
  • Table ‘tblOrderRows’. Scan count 5, logical reads 36, physical reads 0
IO tuning report
Before After Improvement
Duration (ms)*40,000 <1,000~40x
Disk (logical reads)*687,15790~7,635x
*The numbers are an average of multiple T-SQL runs

Overall, the query ran about 40 times faster.

Many will say 'it shouldn’t matter', but with big apps, there’s always a chance of finding unexpected problems. It might not be an issue, or it might.

The point is to be careful.

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 ➜