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. 2017.4.5 Strom

    Strom是分布式实时计算系统,它对于实时计算的意义类似于hadoop对于批处理的意义.与Storm关系密切的语言:核心代码用clojure书写,实用程序用python开发,使用java开发拓扑. S ...

  2. 《DSP using MATLAB》Problem5.33

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  3. zabbix自定义触发器进行监控

    给某一主机创建触发器 触发器属性,其中centos是主机名,也就是你监控的那台主机的名字,可以点击bp2,查看该主机的hostname 检测该触发器 在该主机下可以看到刚创建的触发器 最后我们给该主机 ...

  4. zabbix监控mysql最简单的方法

    该实验基于我的上一篇文章监控第一台主机的基础上 首先,因为水平有限,我选择直接关闭了防火墙和SELinux. 环境: 两台centos7,服务器端IP是192.168.200.128(以下简称主机), ...

  5. 使用distillery&&docker 部署phoenix 应用

      distillery 发布了2.0 了,有好多的新的功能 config prodiver 进行环境变量的配置 appup tansforms 插件系统,方便在release 构建的时候进行修改 m ...

  6. for in和for of

  7. 持续集成--Jenkins--1

    持续集成之Jenkins安装部署   1.安装JDK Jenkins是Java编写的,所以需要先安装JDK,这里采用yum安装,如果对版本有需求,可以直接在Oracle官网下载JDK. [root@l ...

  8. $.post() 和 $.get() 如何同步请求

    由于$.post() 和 $.get() 默认是 异步请求,如果需要同步请求,则可以进行如下使用: 在$.post()前把ajax设置为同步:$.ajaxSettings.async = false; ...

  9. NoHttpResponseException

    采用JMeter2.13做Http性能测试时,在高并发请求的情况下,服务器端并无异常,但是Jmeter端报错NoHttpResponseException (the target server fai ...

  10. 高级java必会系列一:常用线程池和调度类

    众所周知,开启线程2种方法:第一是实现Runable接口,第二继承Thread类.(当然内部类也算...)常用的,这里就不再赘述. 一.线程池 1.newCachedThreadPool (1)缓存型 ...