Search code examples
sql-serverdatabase-performance

Why the Execution time for Same SQL Query varies?


I am executing a stored procedure on my machine in SSMS and database is located on Server.

The stored procedure works properly, but every time it takes different time to execute even if all parameters are the same. Execution time varies from 1 minutes to 8 minute. I am not able to find reason for this and I am not using any DBCC command in between.

Please share your thoughts on this


Solution

  • Multiple possible reasons.

    1. Slow disk, too little RAM - other operations load different data to cache
    2. Corrupted disk - sometimes read operations delay
    3. Heavy CPU usage in your procedure - other processes eat CPU away
    4. Locking problems - other operations lock required tables sometimes