[转][Dapper]参数化查询慢
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]参数化查询慢的更多相关文章
- SQL 语句在查询分析器执行很快,程序 Dapper 参数化查询就很慢(parameter-sniffing)
		这个问题困扰我好长时间了,使用SQLSERVER 事务探查器找到执行超时的SQL语句,参数查询都是通过执行exe sp_executesql 的存储过程调用,因为它能够分析并缓存查询计划,从而优化查询 ... 
- 使用Dapper进行参数化查询
		在使用Dapper操作Mysql数据库中我介绍了使用dapper进行CURD基本操作,但在示例代码中参数虽然也是通过@开头,但其实不是真正意义的参数化查询,而是拼接sql,这种方式不利于防止sql注入 ... 
- SQL参数化查询自动生成SqlParameter列表
		string sql = @"INSERT INTO stu VALUES (@id,@name) "; 参数化查询是经常用到的,它可以有效防止SQL注入.但是需要手动去匹配参数@ ... 
- Sql Server参数化查询之where in和like实现详解
		where in 的参数化查询实现 首先说一下我们常用的办法,直接拼SQL实现,一般情况下都能满足需要 string userIds = "1,2,3,4"; using (Sql ... 
- 【转】浅析Sql Server参数化查询
		转载至: http://www.cnblogs.com/lzrabbit/archive/2012/04/21/2460978.html 错误认识1.不需要防止sql注入的地方无需参数化 参数化查询就 ... 
- 【转】Sql Server参数化查询之where in和like实现之xml和DataTable传参
		转载至: http://www.cnblogs.com/lzrabbit/archive/2012/04/29/2475427.html 在上一篇Sql Server参数化查询之where in和li ... 
- 【转】Sql Server参数化查询之where in和like实现详解
		转载至:http://www.cnblogs.com/lzrabbit/archive/2012/04/22/2465313.html 文章导读 拼SQL实现where in查询 使用CHARINDE ... 
- Oracle参数化查询
		Oracle参数化查询默认是根据顺序绑定的 select * from table where name=:p1 and (select id from table2 where name=:p1); ... 
- SQL  参数化查询 应用于  Like
		在sql 进行参数化查询的时候,使用like 语句和参数的时候,错误的写法: Participant like '%@Participant%' ,这样在数据库为解析为 '%'participant ... 
随机推荐
- XML映射配置文件
			XML映射配置文件 http://www.mybatis.org/mybatis-3/configuration.html Type Handlers 类型处理器 每当MyBatis在Prepared ... 
- ISCC的 Misc——WP
			比赛已经结束了,自己做出来的题也不是很多,跟大家分享一下 Misc 第一题:What is that? 下载链接; 打开 解压 是一个图片 因为分值很少所以题和简单 观察图片是一个向下指的手 说明fl ... 
- day7大纲
			01 昨日内容回顾 数据类型补充: str <---> list split join list <---> set set(list) list(set()) list &l ... 
- InvokeRequired和Invoke(转)
			C#中禁止跨线程直接访问控件,InvokeRequired是为了解决这个问题而产生的,当一个控件的InvokeRequired属性值为真时,说明有一个创建它以外的线程想访问它.此时它将会在内部调用ne ... 
- git 查看提交历史
			查看提交历史 git log 查看每次提交的具体改动内容 git log -p 查看某个文件历次提交的具体改动内容 git log -p <file name> # git log -p ... 
- scala IDE for Eclipse开发Spark程序
			1.开发环境准备 scala IDE for Eclipse:版本(4.6.1) 官网下载:http://scala-ide.org/download/sdk.html 百度云盘下载:链接:http: ... 
- mysql_test
			------------------ #/bin/sh binlogfile=$1 if [ ! -n $binlogfile ]thenecho "pls input your mysql ... 
- innobackupex
			time innobackupex --defaults-file=/data/mysql/3306/my.cnf --user=root --password=123456 \--rsync --p ... 
- QQ检测登陆及QQ协议
			QQ协议分析及还原 http://blog.csdn.net/qinggebuyao/article/details/7814499 腾讯的网站如何检测到你的 QQ 已经登录? http://blog ... 
- NDK学习笔记(二)
			花了点时间把pixeliop的部分看完了,拿到开发文档提供的案例稍事修改,把画面左半边压暗. 这个案例重点在于理清pixel_engine()函数中的坐标与scanline的关系. y代表当前正在调用 ... 
