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.
The execution time was 53 minutes or 3,200,290 ms.
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.