SQL超时在快速查询中过期 [英] SQL timeout expired on fast query

查看:148
本文介绍了SQL超时在快速查询中过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我一直在收到以下超时异常:


  System.Data.SqlClient.SqlException:

超时已过期。在
操作完成之前经过的超时时间
或服务器不是
响应。
该语句已被终止。


我运行大量的查询(100k +),并不是任何一个导致异常的特定查询 - 有时我设法完成所有这些异常。



某些异常来自于作为较大事务的一部分运行的查询,其中一些来自自己运行的查询。



当我直接在SQL Server Management Studio中运行相同的查询时,它们花费的时间不到一秒钟。



我使用samme SQLConnection对象所有的查询,但每个新的SQLCommand对象。



当我尝试使用SQL Server分析器时,它只是说批处理/ RPC已经完成。 >

为什么我随机得到这个异常?

解决方案

可能是由于阻塞 - 也许是时候出现的时候,正在等待另一个进程阻止为了释放锁。这可以解释为什么看起来似乎是随机的,因为这取决于当时的情况。


I am doing some heavy lifting in an SQL database, from C#.

I keep getting the following timeout exception:

 System.Data.SqlClient.SqlException:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.

I run a large number of queries (100k+), and it isn't any one specific query that causes the exception - some times I manage to finish all of them with no exception.

Some of the exceptions come from queries run as part of a larger transaction, some of them come from queries run on their own.

When I run the same query directly in SQL Server Management Studio, they take less than a second to run.

I use the samme SQLConnection object for all the queries, but new SQLCommand object for each.

When I try using the SQL Server profiler, it just says that the batch/RPC has been completed.

Why am I getting this exception at random?

解决方案

It could be due to blocking - perhaps the times when it does time out, it's being blocked by another process that it's waiting for to release locks. This would explain why it appears seemingly at random as it depends on what's going on at the time.

这篇关于SQL超时在快速查询中过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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