SQL Performance Tuning Report – 24,000x faster!

Real sample

Here what can be done during a session of SQL performance tuning.

This query was running for a long time, causing a blocking chain and High CPU usage.

It was also preventing other sessions and the index maintenance job from completing.

Test environment

All the tests were executed on the DEV server against a database restored from the PROD server.

The query was executed a few times and tested possible solutions to improve the performance and fix the query issue.

Solution

After many tests, it was clear that the problem was a NOT IN operation calling a view without a where clause, which causes a massive number of reads.

Original query

Figure 1- Original query that was causing some issues.

Query modified

The NOT IN operation for a NOT EXISTS operation was changed as per the query below (See the highlights).

Figure 2- Query after modifications.

Comparing the results

As expected, the same output (result set) was presented by the original and modified query.

Small changes can lead to big improvements!

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.

Contact us! We tune slow SQL Servers every day. For over a DECADE now.

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

Your email address will not be published. Required fields are marked *

4.8/5

42

TESTIMONIALS