随着时间的推移,存储过程返回的数据集变得非常慢。如果重新编译存储过程,则速度很快。 [英] Dataset returned by stored procedure is becoming very slow with time. Again it is fast if the stored procedure is recompiled.

查看:89
本文介绍了随着时间的推移,存储过程返回的数据集变得非常慢。如果重新编译存储过程,则速度很快。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临着使用存储过程从数据库中提取记录的问题。我们的环境是ASP.NET 2.0 Web应用程序和SQL Server 2008.我们正在使用Microsoft Data Access Application Block dlls。

代码如下:
Dim dbLegal As Database = DatabaseFactory.CreateDatabase(CONNECTION_STRING)
Dim dbCmdLegal As DbCommand = dbLegal.GetStoredProcCommand(PROC_ATS_ORDER_SEARCH)
设置输入参数
searchList = dbLegal.ExecuteDataSet (DBC mdLegal)

现在的问题是,如果我们编译存储过程,记录将在3-4秒内获取。但是经过几天相同数量的记录,开始花费越来越多的时间,最终导致超时错误。虽然独立存储过程花费的时间较少。如果我们重新编译存储过程,整个过程会变得更快。除了增加CommandTimeout属性之外,还有什么可能解决这个问题?请建议。

Hi,
I am facing an issue regarding records being fetched from database using a stored procedure. Our environement is ASP.NET 2.0 web application and SQL Server 2008. We are using Microsoft Data Access Application Block dlls.

The code is like below:
Dim dbLegal As Database = DatabaseFactory.CreateDatabase(CONNECTION_STRING)
Dim dbCmdLegal As DbCommand = dbLegal.GetStoredProcCommand(PROC_ATS_ORDER_SEARCH)
Set Input parameters
searchList = dbLegal.ExecuteDataSet(dbCmdLegal)

Now the issue is, if we compile the stored procedure the records are fetched within 3-4 seconds. But after a few days the same number of records, start taking more and more time, eventually resulting in timeout error. Though the stand alone stored procedure takes lesser time. Again if we recompile the stored procedure the whole process becomes faster. This issue goes on recurring in the

What can be a probable solution to this other than increasing the CommandTimeout property? Please suggest.

推荐答案

Hi Aniruddha Mukhopadhyay,

您可以设置超时时间连接字符串。

本文档有设置超时属性的示例。

< span style ="font-size:10pt; font-family:'Verdana','sans-serif'"lang = EN-US> http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx

其他可能有用的文件:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx

http://msdn.microsoft.com/en-us/library/cc309171.aspx

这对你有用吗?如果您有任何问题或疑虑,请更新主题,我们将进一步讨论。

最好的问候

Yichun Feng


这篇关于随着时间的推移,存储过程返回的数据集变得非常慢。如果重新编译存储过程,则速度很快。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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