Sunday, July 29, 2007

SQL Server - Clearing Cache

For analyzing a query performance - we need to clear the SQL Server cache (both data and execution plans).

To clear all data from cache - use command DBCC DROPCLEANBUFFERS;
Check out http://msdn2.microsoft.com/en-us/library/ms187762.aspx for more details.

To clear all execution plans from cache - use command DBCC FREEPROCCACHE;
Check out http://msdn2.microsoft.com/en-us/library/ms174283.aspx for more details.

To clear execution plans of a particular database from cache - use command DBCC FLUSHPROCINDB(databaseId). FLUSHPROCINDB is an undocumented command.

0 Comments:

Post a Comment

<< Home