Tuesday, January 12, 2010

Sql Server cache

To clean cache:

DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE

To view cache list (SQL 2005):

SELECT objtype, p.size_in_bytes, t.[text], usecounts
FROM sys.dm_exec_cached_plans p
OUTER APPLY sys.dm_exec_sql_text (p.plan_handle) t
WHERE objtype IN ('Prepared', 'Adhoc')
ORDER BY usecounts DESC

1 comment:

Anonymous said...

Hi - I am really delighted to find this. great job!