SqlDataReader的性能降低 [英] Slow performance of SqlDataReader

查看:203
本文介绍了SqlDataReader的性能降低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经查询了在MSSMS中执行大约2秒钟(返回25K行)

I've query executing ~2 secs in MSSMS (returning 25K of rows)

.NET(sqlReader)中使用的相同查询会占用几分钟!

Same query used in .NET (sqlReader) exetuting few minutes!

我也尝试只执行读取器

(注释了while循环中的所有代码只是离开了reader.Read() )-还是一样!

(commented all code in while loop just leaving reader.Read() ) - still same!

知道什么了吗?

我不是DBA,也没有特权与Profiler一起玩-会问我的DBA,并让所有人知道。

I'm not DBA and not priviledged to play with Profiler - will ask my DBA and let all know.

与此同时,我注意到在添加后我在说SP的参数 可以修改

In the meantime I'm noticed essential performance boost after adding "WITH RECOMPILE" param to SP I'm talking

因此,从我的角度来看,执行计划似乎就是这种情况...
您如何看待?

So, from my perspective it seems to be the case with execution plan... What do you think?


我还检查了以下内容,是如何执行质量检查和.NET

Also what I've checked was performing below query from QA and .NET

select @@options

我的理解是,这两种环境都应返回相同的值。
(如果不使用,则将使用exnetnet ex.plans)
是吗?

My understanding is it shall return same value for both environements. (If not differnet ex.plans will be used) Am I right?


我已阅读(来自 http://www.sqldev.net/misc/fn_setopts.htm )表示 ARITHABOIRT =在质量检查中处于启用状态(在.NET中处于关闭状态)

I've read (from http://www.sqldev.net/misc/fn_setopts.htm) that ARITHABOIRT=ON in QA (in .NET it is off)

有人知道如何强制ARITHABOIRT = ON对于每个.NET连接?

Does enybody know how to force ARITHABOIRT=ON for every .NET connections?

推荐答案

我将在SQL Server Profiler中设置跟踪,以查看连接的SET选项设置从.NET代码连接时使用什么,以及SSMS中正在使用哪些设置。通过SET选项设置,我的意思是

I would set up a trace in SQL Server Profiler to see what SET options settings the connection is using when connecting from .NET code, and what settings are being used in SSMS. By SET options settings, I mean

ARITHABORT
ANSI_NULLS
CONCAT_NULL_YIELDS_NULL
//etc

看看 MSDN 以获得选项表

我之前在哪里看到了问题选项不同(在这种情况下, ARITHABORT ),并且性能差异很大。

I have seen the problem before where the options were different (in that case, ARITHABORT) and the performance difference was huge.

这篇关于SqlDataReader的性能降低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆