SQL SERVER – How to Clear Plan Cache with Database Scoped Configuration?

I can Clear Plan Cache for the current database through database-scoped configuration. I verify the context before considering eviction.

One empty template compartment sits above its removed guides, while neighboring compartments and finished products remain intact.

SELECT name, value, value_for_secondary
FROM sys.database_scoped_configurations
ORDER BY name;
-- Only after selecting and confirming the intended database:
-- USE [YourDatabase];
-- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;

Select the intended database before executing the commented statement. It clears cached plans associated with that database, not the database buffer pool or every cache on the instance. An unqualified DBCC FREEPROCCACHE has a broader instance-level scope, so the two commands don’t have the same reach.

After removal, queries may compile new plans and consume extra CPU. This can help a controlled diagnosis, but clearing cache repeatedly is not a performance fix. Capture evidence and compare the affected workload before deciding to evict plans.

The SQL Server 2016 article described four early database-scoped options. Current releases expose many more, and the read-only query lists what this engine supports. Availability and permissions depend on the release and platform.

Reference: CLEAR PROCEDURE_CACHE.

Database plan eviction is not data-buffer clearing, it is removal of cached plans associated with that database.

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.

Execution Plan, SQL Cache, SQL Scripts, SQL Server, SQL Server Configuration
Previous Post
SPID, KPID and ECID in sys.sysprocesses: What They Mean
Next Post
SQL SERVER – SQL Agent Not Starting. The EventLog Service has Not Been Started

Related Posts

2 Comments. Leave new

  • Hi sir,i have one query regarding cache clean…when is really required to clean cache??as sql server manages available memory appropriately…means when query required memory than it will get assigned from available memory and if it is less than available memory than dirty pages in memory get return back to memory and clean pages get flush from memory..so what is the need to clean catche???

    Reply
  • If we want to check the execution plan of a query again after making some changes, we need to clear the cache to get rid of the old plans that are cached in memory.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.