sqlserver缓存计划-清除只使用一次的缓存计划
发布时间:2020-12-12 12:49:19 所属栏目:MsSql教程 来源:网络整理
导读:plan cache很大,将只使用一次的缓存计划清除,而不用清除整个cache.declare @sid varbinary(64)declare cur01 cursor forselect plan_handle from (SELECT plan_handle FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_sql_text(cp.plan_hand
plan cache很大,将只使用一次的缓存计划清除,而不用清除整个cache. declare @sid varbinary(64) declare cur01 cursor for select plan_handle from ( SELECT plan_handle FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc',N'Prepared') AND cp.usecounts =1 and text like 'select%' ) c open cur01 fetch next from cur01 into @sid while @@fetch_status=0 begin DBCC FREEPROCCACHE(@sid) fetch next from cur01 into @sid end close cur01 deallocate cur01 go (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |