--1. Writes all dirty pages of the current database to disk. A dirty page is a page of data that has been entered into a buffer cache and has been modified but not yet written to disk. -- CHECKPOINT can create a checkpoint that guarantees that all dirty pages have been written to disk, saving time in a later recovery process. Checkpoint--2. To remove the purge buffer from the buffer pool, first use CHECKPOINT to generate a cold cache. This forces all dirty pages of the current database to be written to disk, and then clears the buffer. -- Once this is done, you can issue the DBCC dropcleanbuffers command to remove all buffers from the buffer pool. DBCC dropcleanbuffers--3. Releasing the process cache causes the system to recompile some statements (for example, ad hoc SQL statements) without reusing the statements in the cache. DBCC freeproccache--4. Frees all unused cache entries from all caches. SQL Server 2005 Database Engine cleans unused cache entries in the background beforehand so that memory is available for the current entry. -- However, you can use this command to manually remove unused entries from all caches. DBCC Freesystemcache (' all ')--5. To proceed with your query, SQL Server will automatically read the most likely data page into the cache at all times.
CHECKPOINT;DBCC dropcleanbuffers;dbcc freeproccache;dbcc freesystemcache (' all '); Set STATISTICS time on;--Query condition set STATISTICS time OFF;
SQL Server clears the cache, logs the query time