Time given back
~11 minof waiting removed every hour
It runs hundreds of times an hour, and every call made the app wait. At 200 calls an hour, that was 684 seconds (11.4 minutes) of waiting every hour; now it is about 6 seconds.
Waiting per hour (at 200 calls an hour)
Assumption: 200 calls an hour, the low end of the post’s “hundreds of times per hour”. Waiting per hour = 200 calls × 3.42 s = 684 s (11.4 min) before, and 200 × 31 ms = 6.2 s after. Source: 6 measured runs.
Reading from disk is SQL Server's slowest operation, making the reduction of disk reads a primary target for tuning.
Less disk pressure means the server can do more with less
The bottleneck for most SQL Servers is disk access (or disk “reads”).
It's neither the CPU nor the RAM, which are usually the first suspects for most customers.
And that makes much sense. Here is why:
- Inefficient queries scan (or read) much data.
- Data read in is stored in RAM. As more data is read in, “older” data is pushed out from RAM.
- If there isn’t enough RAM to keep ALL data in memory (which is often not possible), SQL Server has to read from disk, and that is the slowest operation SQL Server can do.
- When the query can be tuned to read 10 rows vs. 10 million, less CPU and RAM automatically are necessary.
Disk is one of the most common SQL Server bottlenecks, so reducing the disk reads is usually the primary objective.
For the end-user, nothing is more important than the speed (or duration) of the query, in every case.
Tuning to reduce CPU/RAM resources is helpful too.
The problem
A stored procedure that ran hundreds of times per hour was taking too long.
The fix
The fix involved multiple code changes in the stored procedure to reduce the number of disk reads.
The transformation drastically cut execution time from 3,420 ms to about 31 ms.
Here’s the before-and-after snapshot that showcases the efficiency gains:

Final thoughts
After our tuning, the stored procedure ran 111 times faster.
CPU time dropped 139 times and disk reads dropped 278 times.
Under the hood
Every run, before and after
We took 6 separate runs to analyze the query performance before and after the fix:
| Run | Duration (ms) | CPU (ms) | Disk (8k page reads) | |||
|---|---|---|---|---|---|---|
| Before | After | Before | After | Before | After | |
| Run 1 | 3,833 | 32 | 3,844 | 31 | 53,658 | 231 |
| Run 2 | 193 | 26 | 188 | 31 | 25,799 | 162 |
| Run 3 | 4,654 | 24 | 4,656 | 15 | 65,655 | 167 |
| Run 4 | 3,287 | 31 | 3,250 | 31 | 45,807 | 225 |
| Run 5 | 4,187 | 43 | 4,156 | - | 61,039 | 151 |
| Run 6 | 4,367 | 28 | 4,375 | 15 | 66,738 | 214 |
| AVG | 3,420 | 30.7 | 3,411 | 24.6 | 53,116 | 191 |
When queries are tuned to need less CPU & RAM, it means that the same server now has more capacity.


