Performance Tuning - Do you make sure to clear SQL server cache when performing benchmark tests?
Updated by Brady Stroud [SSW] 1 year ago. See history
All well and good but when you are trying to speed up an existing query that is taking some time then you may not be making a difference even though your execution times are way down.
You really need to clear SQL's cache (or buffer) every time you test the speed of a query. This prevents the data and/or execution plans from being cached, thus corrupting the next test.
To clear SQL Server's cache, run DBCC DROPCLEANBUFFERS
, which clears all data from the cache. Then run DBCC FREEPROCCACHE
, which clears the stored procedure cache.

Figure: First call is after clearing the cache, the second one is without clearing the cache (26 seconds vs 2 seconds)
Categories
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.