I want to clear out the procedure cache for just one database, not the entire SQL Server. Is there a way?
2 Answers
DBCC FLUSHPROCINDB (<db_id>)
This command allows you to specify a particular database id, and then clears all plans from that particular database. Check more information here.
DBCC FREEPROCCACHE
This command removes all cached plans from memory
It is, of course, recommended that you don’t use these commands on your production servers, as it could impact the performance of your running applications. Usually, you want to keep plans in cache.
-
1Thanks for your answer. I used
SELECT DB_ID('<db_name>')
to get the database id.– ScottAug 14, 2019 at 16:23
Another way to clear cache is to use DBCC freesystemcache
DBCC FREESYSTEMCACHE ('userdatabase') -- cleans cache for specific user database