码迷,mamicode.com
首页 > 移动开发 > 详细

[转][Dapper]参数化查询慢

时间:2018-08-30 14:27:47      阅读:607      评论:0      收藏:0      [点我收藏+]

标签:roc   cache   https   log   tar   creat   div   nbsp   DApp   

 
if object_id(tempdb..#t_remove_expired_plan) is not null
    drop table #t_remove_expired_plan
GO

create table #t_remove_expired_plan
(
    id int identity(1,1),
    plan_handle varbinary(500)
)
GO


insert into #t_remove_expired_plan (plan_handle) 
select  qs.plan_handle
from sys.dm_exec_query_stats qs 
where creation_time< dateadd(hh,-24,getdate())
GO


declare @exists_data bit = 1
declare @v_plan_handle varbinary(500)
declare @str_sql varchar(1000)
while @exists_data = 1
begin
    select top 1 @v_plan_handle = plan_handle from #t_remove_expired_plan
    if(@v_plan_handle is not null)
    begin
        execute sp_executesql NDBCC FREEPROCCACHE(@plan_handle) ,N@plan_handle varbinary(500),@plan_handle = @v_plan_handle
    end
    delete top (1) from #t_remove_expired_plan

    if exists(select 1 from #t_remove_expired_plan)
    begin
        set @exists_data = 1
    end
    else 
    begin
        set @exists_data = 0
    end
end

 参考:https://www.cnblogs.com/quanweiru/p/5577421.html

[转][Dapper]参数化查询慢

标签:roc   cache   https   log   tar   creat   div   nbsp   DApp   

原文地址:https://www.cnblogs.com/z5337/p/9559719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!