14

Currently I run DBCC FREEPROCCACHE when I want to wipe information out of the buffer pool between running SQL queries. However, I was reviewing this Technet article referencing DBCC FREESYSTEMCACHE. What caches does FREESYSTEMCACHE wipe that FREEPROCCACHE doesn't?

1 Answer 1

27

What caches does FREESYSTEMCACHE wipe that FREEPROCCACHE doesn't?

There are many system caches available in SQL Server. I am referring to SQL 2008R2 (as I tested on it).

Below query will return all the caches available :

--- ONLY for Educational purpose. Don't attempt to run on PROD !!

select 'DBCC freesystemcache ('+''''+name+''''+')'  from   sys.dm_os_memory_clerks group by name
-- 155 rows

so for e.g. you want to clear all caches you will run

DBCC FREESYSTEMCACHE ('ALL')

for specific caches to be cleared you can run

DBCC FREESYSTEMCACHE ('userdatabase') -- cleans cache for specific user database
DBCC FREESYSTEMCACHE ('tempdb')  -- clears cache for tempdb
DBCC FREESYSTEMCACHE ('Temporary Tables & Table Variables') -- clears all the temp table and variables
.. and many more (see above 155 rows returned from sql server 2008R2)

Using FREEPROCCACHE, you wont be able to clear all above mentioned at that detailed level.

FREEPROCCACHE ==> from BOL

Removes all elements from the plan cache, removes a specific plan from the plan cache by specifying a plan handle or SQL handle, or removes all cache entries associated with a specified resource pool.

So essentially, you might think of it as only related to Plan cache with the ability to remove specific plans from the cache with the plan handle and or pool name.

Fun With DBCC FREEPROCCACHE is a blog from Glenn Berry

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.