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. SVN三种合并类型

    https://blog.csdn.net/zht666/article/details/36178117 转自:http://wenku.baidu.com/link?url=pnALYESJnX0 ...

  2. 如何安装psutil以及提示缺少python.h头文件

    下载psutil 下载地址https://pypi.python.org/packages/57/93/47a2e3befaf194ccc3d05ffbcba2cdcdd22a231100ef7e4c ...

  3. MySQL Binlog--MIXED模式下数据更新

    在 Mixed 模式下,MySQL 会根据执行的每一条具体的 SQL 语句来区分对待记录的日志形式,也就是在 statement 和 row 之间选择一种.如果SQL语句为UPDATE/DELETE等 ...

  4. Creating Modules

    转自官方文档,主要说明如何创建模块 https://www.terraform.io/docs/modules/index.html A module is a container for multi ...

  5. day 3 大纲笔记

    01 昨日内容回顾 while 条件: 循环体 如何终止循环: 1,改变条件. 2,break. 3,exit() quit() 不推荐. 关键字: break continue while else ...

  6. .Net Core 应用方向 图谱

    .Net Core 应用方向 图谱,  如下图 : 大规模并行计算 是 大数据 和 人工智能 的 基础, 是 未来 大计算能力 的 基础, 网格计算 是 未来 大计算能力 的 一个 分支 . 所以, ...

  7. 用react编写一个hello world

    我要分享的是用react搭建一个简单的hello world, 一个小demo, 大神请略过 首先看一下目录结构 创建一个目录, 用于存放demo mkdir reactHello cd reactH ...

  8. Webpack4 的 Tree Shaking:babel-loader设置modules: false,还是设置"sideEffects": false,待确定

    Webpack4 的 Tree Shaking:babel-loader设置modules: false,还是设置"sideEffects": false,待确定 babel-lo ...

  9. gaea-editor 知识点

    github 地址:https://github.com/ascoders/gaea-editor

  10. create-react-app 搭建的项目中,使用 stylus

    相关介绍文章: react学习系列1 修改create-react-app配置支持stylus:https://www.jianshu.com/p/9cd7a0dff11f 在react中使用styl ...