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 N'DBCC 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]参数化查询慢的更多相关文章

  1. SQL 语句在查询分析器执行很快,程序 Dapper 参数化查询就很慢(parameter-sniffing)

    这个问题困扰我好长时间了,使用SQLSERVER 事务探查器找到执行超时的SQL语句,参数查询都是通过执行exe sp_executesql 的存储过程调用,因为它能够分析并缓存查询计划,从而优化查询 ...

  2. 使用Dapper进行参数化查询

    在使用Dapper操作Mysql数据库中我介绍了使用dapper进行CURD基本操作,但在示例代码中参数虽然也是通过@开头,但其实不是真正意义的参数化查询,而是拼接sql,这种方式不利于防止sql注入 ...

  3. SQL参数化查询自动生成SqlParameter列表

    string sql = @"INSERT INTO stu VALUES (@id,@name) "; 参数化查询是经常用到的,它可以有效防止SQL注入.但是需要手动去匹配参数@ ...

  4. Sql Server参数化查询之where in和like实现详解

    where in 的参数化查询实现 首先说一下我们常用的办法,直接拼SQL实现,一般情况下都能满足需要 string userIds = "1,2,3,4"; using (Sql ...

  5. 【转】浅析Sql Server参数化查询

    转载至: http://www.cnblogs.com/lzrabbit/archive/2012/04/21/2460978.html 错误认识1.不需要防止sql注入的地方无需参数化 参数化查询就 ...

  6. 【转】Sql Server参数化查询之where in和like实现之xml和DataTable传参

    转载至: http://www.cnblogs.com/lzrabbit/archive/2012/04/29/2475427.html 在上一篇Sql Server参数化查询之where in和li ...

  7. 【转】Sql Server参数化查询之where in和like实现详解

    转载至:http://www.cnblogs.com/lzrabbit/archive/2012/04/22/2465313.html 文章导读 拼SQL实现where in查询 使用CHARINDE ...

  8. Oracle参数化查询

    Oracle参数化查询默认是根据顺序绑定的 select * from table where name=:p1 and (select id from table2 where name=:p1); ...

  9. SQL 参数化查询 应用于 Like

    在sql 进行参数化查询的时候,使用like 语句和参数的时候,错误的写法:  Participant like '%@Participant%' ,这样在数据库为解析为 '%'participant ...

随机推荐

  1. Socket远程桌面

    自建Socket转发,使用远程桌面(mstsc)连接家中电脑   网络结构图如下: 开题先放图,一切全靠编哈哈. 进入正题! 如图所示,我们需要一个公网服务器,利用公网服务器将内网的数据进行转发,从而 ...

  2. 服务器-华为RH2288H V3-Server 2008R2忘记登录密码操作方法

    1.插入PE盘,重启服务器. 下载地址:http://pan.baidu.com/s/1c16cP6C 密码: 18hq 注:这是支持全系列阵列卡的专用服务器PE工具,市面上的绝大多数PE在服务器中都 ...

  3. Linux下mysql出错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    安装: 1.新开的云服务器,需要检测系统是否自带安装mysql # yum list installed | grep mysql 2.如果发现有系统自带mysql,果断这么干 # yum -y re ...

  4. opencv掩模操作

    //设置变量,读图 Mat image, mask; Mat img1, img2, img3, img4; image = imread("data/img/1.jpg"); / ...

  5. django ---forms组件

    forms组件 本文目录 1 校验字段功能 2 渲染标签功能 3 渲染错误信息功能 4 组件的参数配置 5 局部钩子 6 全局钩子 回到目录 1 校验字段功能 针对一个实例:注册用户讲解. 模型:mo ...

  6. 微处理器CPU 50年

    CPU50年 ===电子管时期1912年:美国青年发明家德.福雷斯特(L.De Forest)在帕洛阿托小镇首次发现了电子管的放大作用.1946年:地球上第一台电子数字式计算机(ENIAC(埃尼阿克) ...

  7. 【单位矩阵】【杭电OJ1575】

    Tr A Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  8. 【BZOJ1930】【SHOI2003】吃豆豆

    初见杀…… 原题: 两个PACMAN吃豆豆.一开始的时候,PACMAN都在坐标原点的左下方,豆豆都在右上方.PACMAN走到豆豆处就会吃掉它.PACMAN行走的路线很奇怪,只能向右走或者向上走,他们行 ...

  9. HTTP与TCP的区别和联系--转载

    相信不少初学手机联网开发的朋友都想知道Http与Socket连接究竟有什么区别,希望通过自己的浅显理解能对初学者有所帮助. 一.基本概念 1.TCP连接 手机能够使用联网功能是因为手机底层实现了TCP ...

  10. 刚开始学java和刚去工作的时候,1.path路径 2.classpath路径 还有JAVA_HOME相当于/dgs这个路径

    把里面bin文件夹下面的可执行文件都配置到path路径下了,以后只要在Dos窗口输入命令就可以运行 无论是在dos窗口下还是在eclispe中只需要配置这个path变量,不需要配置classpath ...