patternsqlMajor
SQL Server commands to clear caches before running a performance comparison
Viewed 0 times
sqlcommandscomparisonrunningcachesperformanceclearserverbefore
Problem
When comparing the execution time of two different queries, it's important to clear the cache to make sure that the execution of the first query does not alter the performance of the second.
In a Google Search, I could find these commands:
In fact, my queries are taking a more realistic time to complete after several executions than before. However, I'm not sure this is the recommended technique.
What's the best practice?
In a Google Search, I could find these commands:
DBCC FREESYSTEMCACHE
DBCC FREESESSIONCACHE
DBCC FREEPROCCACHEIn fact, my queries are taking a more realistic time to complete after several executions than before. However, I'm not sure this is the recommended technique.
What's the best practice?
Solution
Personally, for a common query the 2nd and subsequent executions matter more.
Are you testing disk IO or query performance?
Assuming your query runs often and is critical, then you want to measure that under real life conditions. And you don't want to clear prod server caches each time...
If you want, you can:
Precede that with a
Also see (on DBA.SE)
Are you testing disk IO or query performance?
Assuming your query runs often and is critical, then you want to measure that under real life conditions. And you don't want to clear prod server caches each time...
If you want, you can:
DBCC DROPCLEANBUFFERSclears clean (unmodified) pages from the buffer pool
Precede that with a
CHECKPOINT to flush any dirty pages to disk firstDBCC FLUSHPROCINDBclears execution plans for that database
Also see (on DBA.SE)
- Solving high page load time using SQL Profiler
Context
StackExchange Database Administrators Q#10818, answer score: 48
Revisions (0)
No revisions yet.