Comprehensive SQL Performance Monitoring and Optimisation Script

  • Comments posted to this topic are about the item Comprehensive SQL Performance Monitoring and Optimisation Script

  • I've written the script in the link above query and am using it. I've found that for a few of the of the rows it occasionally reports negative statistics. i.e. for a few percent of the queries it reports negative total_cpu_time, total_IO, total_physical_reads etc.

    Explanation of the query

    The script operates by first inserting statistics into a temporary table, marking each row with an Identifier = 1. After a specified wait period, the query runs again, inserting additional rows into the same temporary table, this time marked with Identifier = 2.

    In the final step, the script queries the temporary table, calculating the difference between the rows with Identifier = 1 and those with Identifier = 2. This process effectively captures and displays the change in metrics, such as the number of executions, total CPU usage, and other resource statistics, over the time period that the script has been running.

    I was thinking it might be that the plan gets evicted from the cache, but then if that was the case the plan would have to come back in again with exactly the same plan handle.

    Does anyone know how it could arrive at negative results?

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply