什么是执行耗时功能的最佳方法 [英] what is the best way to execute a time consuming function

查看:75
本文介绍了什么是执行耗时功能的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我在asp.net中有一个页面,它执行一个生成查询的函数来更新数据库中的多行



该功能需要很长时间才能完成,导致等待操作超时异常



什么是执行此功能的最佳方法,并跳过系统长时间执行的超时异常



建议我选择处理此类问题。



请注意我的数据库有大量数据,更新多行时出现此错误



我正在使用的查询是:

Hello,

I have a page in asp.net that execute a function that generate a query to update multiple row from a database

that function is taking a long time to finish which lead to a "The wait operation timed out" exception

what is the best way to execute this function and jump over the time out exception that the system throw on long time execution

suggest me options to deal with such problem.

note that my database has large amount of data and this error appears when updating multiple rows

the query that im using is :"

Update Emails Set Status='Active' Where ID in (" & hardmailsIDs & ")"





函数vb,用于使用循环在字符串(hardmailsIDs)中获取这些ID。



the function vb that is used to get those ids in a string (hardmailsIDs) using a loop ..

For Each dr As DataRow In hardbouncedmail.Rows
                   hardmails = (hardmails & Convert.ToString(",")) + "'" + Convert.ToString(dr("Email") + "'")
                   Dim IdRow() As DataRow = selectedmailIDs.Select("Email='" & dr("Email") & "'")
                   hardmailsIDs = (hardmailsIDs & Convert.ToString(",") + IdRow(0).Item("ID").ToString())
               Next





id的数量可能达到50,000行



谢谢。



the number of id may reach 50,000 row

thanks.

推荐答案

我想你应该考虑使用存储过程,它们肯定不是更快的SQL-Wise,但考虑到你是在代码中使用循环,我相信它们可以有所不同。
I guess you should consider using stored procedures, they are certainly not any faster SQL-Wise, but consider that you are using a loop in your code, I am sure they can make some difference.


这篇关于什么是执行耗时功能的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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