views:

1301

answers:

1

Can someone explain the use of DBCC DROPCLEANBUFFERS together with the CHECKPOINT operator and provide an example?

I understand it is useful to test performances running before your queries but I don't fully grasp it. Also I have no clue about the use in combination with the CHECKPOINT operator.

If I execute it before my queries they take much longer to run, so I am guessing it is good to compare performances but not to accurately evaluate them.

Any help would be appreciated!

+7  A: 

CHECKPOINT flushes modified data pages to disk:

[CHECKPOINT] Writes all dirty pages for the current database to disk. Dirty pages are data pages that have been entered into the buffer cache and modified, but not yet written to disk. Checkpoints save time during a later recovery by creating a point at which all dirty pages are guaranteed to have been written to disk.

DBCC DROPCLEANBUFFERS then removes any non dirty (iow, clean) pages:

Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server.

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.

The end result is that you're starting with nothing cached.

Mark Brackett