sqlserver緩衝計劃-清除只使用一次的緩衝計劃,sqlserver緩衝

來源:互聯網
上載者:User

sqlserver緩衝計劃-清除只使用一次的緩衝計劃,sqlserver緩衝

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_handle) stWHERE cp.cacheobjtype = N'Compiled Plan'AND cp.objtype IN (N'Adhoc', N'Prepared')AND cp.usecounts =1 and  text   like 'select%') copen cur01fetch next from cur01 into @sidwhile @@fetch_status=0beginDBCC FREEPROCCACHE(@sid)fetch next from cur01 into @sidendclose cur01deallocate cur01go



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.