Sunday 13 January 2013

Clearing SQL Server cache for performance testing

You can restart windows or the windows service, but the more elegant way is to use DBCC DROPCLEANBUFFERS.


To drop clean buffers from the buffer pool, first use CHECKPOINT to produce a cold buffer cache. This forces all dirty pages for the current database to be written to disk and cleans the buffers. After you do this, you can issue DBCC DROPCLEANBUFFERS command to remove all buffers from the buffer pool.


USE MyDatabaseName;
GO

CHECKPOINT;
GO

DBCC DROPCLEANBUFFERS;
GO

No comments:

Post a Comment