SQL Performance Tuning Report #13 – Execution time from 52 minutes to 92 milliseconds?

Real sample #13

Here what can be done when you have one of our DBA plans.

During monitoring session was observed this query running for long time and due to the number of
reads happening the CPU usage went to 70% during execution. There were 12 session running the query:

After review the query plan, it was clear that the problem was a NOT IN operation calling a view.

What have we done?

Something simple! It was changed a NOT IN operation for a NOT EXISTS operation as per query below.

Small changes can lead to big improvements?

Sure!  Take a look, the execution time gone from about an hour to few milliseconds.

Before tuning

The execution time was 53 minutes or 3,200,290 ms.

After tuning

The execution time was 0 seconds or 92 ms.

That’s it! That simple!

But take care, the logical operators NOT IN and NOT EXISTS behave different under certain circumstances, or performance-wise, meaning if using one operator has a performance benefit over the other.

Agree? Disagree? Comment below.

 

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email

Leave a Comment

4.5/5

42

FREE Scripts to Instantly
Improve SQL Server Performance

3 FREE Scripts to Instantly
Improve SQL Server Performance

Learn how to increase Performance of SQL Server INSTANTLY with 3 free scripts.