Clean Cache commands affect different parts of SQL Server memory. I separate buffer-pool testing from execution-plan testing.

The buffer pool holds database pages. The plan cache holds reusable execution plans. Clearing one doesn’t clear the other. I check which cache a test requires before running a command.
-- Isolated test instance only. These commands can affect unrelated workloads.
CHECKPOINT;
DBCC DROPCLEANBUFFERS;
DBCC FREEPROCCACHE;CHECKPOINT writes dirty pages for the current database. DROPCLEANBUFFERS removes clean buffers and supported columnstore cached objects. It does not mean every dirty page from every database has first been written.
FREEPROCCACHE evicts plans. Later executions may compile again. That cost affects other work on a shared instance and can make a timing comparison misleading.
Keep the test conditions comparable
Run the same query and data under documented warm and cold conditions. Record logical reads, physical reads, elapsed time, and the plan. Don’t assume a faster second run proves that changing the query was responsible.
These commands don’t measure application performance by themselves. I keep the query, data and other test conditions comparable. Otherwise, a warmer cache can receive credit for an improvement the query never made.
Reference: DBCC DROPCLEANBUFFERS.
Related reading
- Arrow in Execution Plan – SQL in Sixty Seconds #136
- SSMS Efficiency – Replace STAR – SQL in Sixty Seconds #130
- Cycle Clipboard Ring – SQL in Sixty Seconds #129
- Split Screen for SSMS Efficiency – SQL in Sixty Seconds #120
- Full-Screen Execution Plan – SQL in Sixty Seconds #117
Cache clearing is not a tuning shortcut, it is a controlled test condition.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.
Discover more from SQL Authority with Pinal Dave
Subscribe to get the latest posts sent to your email.





24 Comments. Leave new
Thanks for useful imformation.
You have not mention CHECKPOINT before run DBCC DROPCLEANBUFFERS.
As per MSDN, use CHECKPOINT to produce a cold buffer cache. DBCC DROPCLEANBUFFERS command remove all buffers from the buffer pool.
That means, Not DROPCLEANBUFFERS produce a cold buffer cache, it is CHECKPOINT. And we use DROPCLEANBUFFERS to remove pages from buffer pool. Cold buffer does not mean Buffer is clear.
Hi Pinal Dave
I have a Store Procedure running and this SP running with batch processing. with condition normal, the process around 10-15 minute. but If I try a several time, the process slow time to time, the process take a time until 30-45 minute.
I have do the clear cache with this command.
DBCC SHRINKDATABASE (ForestWork, TRUNCATEONLY);
use ForestWork
DBCC SHRINKFILE([ForestWork_log], 0, TRUNCATEONLY)
DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
DBCC FREESESSIONCACHE
DBCC FREESYSTEMCACHE (‘ALL’) WITH MARK_IN_USE_FOR_REMOVAL;
After clear cache, the process still slow, but sometime the process back to normal about 10-15 minute. but it is only occasionally
Do you know, what we should do? is any cache or log still need to clear again?
Please let me know, if you have any idea.
Best Regards,
Heri
I really wish I can answer this one. It requires more research.