Thursday, March 4, 2010

Clear SQL Server Cache

While working on performance tuning sql queries or procs, the query which took a considerable amount of time to execute the first time will take very less time to execute the second time. The reason behind this was the data getting cached and sql server uses this cached data to publish the results.
To free this cached data use the commands DBCC DROPCLEANBUFFERS and DBCC FREEPROCCACHE.
DBCC DROPCLEANBUFFERS clears all data from the cache. Any data loaded into the buffer cache due to the prior execution of a query is removed.
DBCC FREEPROCCACHE clears the stored procedure cache.

No comments: