SQL SERVER – Stored Procedure – Clean Cache and Clean Buffer

Use DBCC FREEPROCCACHE to clear the procedure cache. Freeing the procedure cache would cause, for example, an ad-hoc SQL statement to be recompiled rather than reused from the cache. If observing through SQL Profiler, one can watch the Cache Remove events occur as DBCC FREEPROCCACHE goes to work. DBCC FREEPROCCACHE will invalidate all stored procedure plans that the optimizer has cached in memory and force SQL Server to compile new plans the next time those procedures are run.

Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server. DBCC DROPCLEANBUFFERS serves to empty the data cache. Any data loaded into the buffer cache due to the prior execution of a query is removed.

DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS

Reference : Pinal Dave (https://blog.sqlauthority.com) , BOL , BOL

Solarwinds
, , , , ,
Previous Post
SQL SERVER – Fix: Error Msg 128 The name is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
Next Post
SQL SERVER – @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record

Related Posts

22 Comments. Leave new

  • Thanks for useful imformation.

    Reply
  • 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.

    Reply

Leave a Reply

Menu