Effort vs result
1 lineof code removed
A leftover MAXDOP hint from an old refactor was limiting the query. Removing it was the whole fix.
Time per run
Source: one run before and one after.
A query hint is a decision someone made for the optimizer.
It can stay in the code long after the reason for it is gone.
The problem
One leftover query hint was making a stored procedure 5.5 times slower. We found it during one of our database assessments.
The procedure had been refactored at some point. But the developers left an old MAXDOP query hint (max degree of parallelism) in place. It limited how many threads the query could use, and it no longer matched what the query did.
Here’s a glance at the pre-tuning metrics:
- Duration (ms): 2,933
The fix
This is what we did to fix the issue: we removed the MAXDOP hint.
We did not add an index or rewrite anything.
Final thoughts
MAXDOP controls parallelism for one query. It can be the right tool, but it is a fixed answer to a question that changes when the code or the data changes.
And temporary fixes tend to stay. A hint added to get through one bad week can still be in your code years later.
When you refactor a query, review its hints too. Each one should still have a reason to be there.
Under the hood
Before and after, every measurement
| Before | After | Improvement | |
|---|---|---|---|
| Duration (ms)* | 2,933 | 531 | 5.5x |


