HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How to clear all plans from a single database?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
howalldatabasesingleclearfromplans

Problem

I want to clear out the procedure cache for just one database, not the entire SQL Server. Is there a way?

Solution

DBCC FLUSHPROCINDB ()


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.

Code Snippets

DBCC FLUSHPROCINDB (<db_id>)
DBCC FREEPROCCACHE

Context

StackExchange Database Administrators Q#148694, answer score: 15

Revisions (0)

No revisions yet.