首页 > 移动平台 > 详细

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

时间:2018-08-30 14:06:51      阅读:313      评论:0      收藏:0      [点我收藏+]
 
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]参数化查询慢

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!