Timeout expired. The timeout period elapsed prior to completion of the operation or the server...

问题:

最近程序总会抛出如下异常:

An exception of type‘System.Data.SqlClient.SqlException‘ occurred and was caught.

----------------------------------------------------------------------------------

Type :System.Data.SqlClient.SqlException, System.Data, Version=4.0.0.0,Culture=neutral, PublicKeyToken=b77a5c561934e089

Message : Timeoutexpired.  The timeout period elapsedprior to completion of the operation or the server is not responding.

Source : .Net SqlClient Data Provider......

......Database.ExecuteReader(DbCommandcommand)......

读取数据超时。

然后就去看了下DataBase里对应的tables,发现table的结构简单,但是数据量很大,有几十万上百万条。再看一下有没有建Indexes/Keys,发现没有,恍然大悟。

解决方法:

根据表的结构,建立了Indexes/Keys下的 Unique key,类似如下:

ALTER TABLE [dbo].[ZData]
 add  CONSTRAINT [IX_ZData] UNIQUE NONCLUSTERED
(
	[Pid] ASC,
	[EntryID] ASC,
	[Date] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF,
SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF,
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

测试,发现速度快很多,减小了timeout的风险。

时间: 2024-11-08 21:53:32

Timeout expired. The timeout period elapsed prior to completion of the operation or the server...的相关文章

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.【转】

今天碰到了一个查询异常问题,上网查了一下,感谢原创和译者 如果你使用的数据库连接类是 the Data Access Application Blocks "SqlHelper" 或者 SqlClient Class , 你在执行一个很费时的SQL 操作时候,可能就会碰到下面的超时异常. --------------------------- ---------------------------Timeout expired.  The timeout period elapsed

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

今天碰到了一个查询异常问题,上网查了一下,感谢原创和译者 如果你使用的数据库连接类是 the Data Access Application Blocks "SqlHelper" 或者 SqlClient Class , 你在执行一个很费时的SQL 操作时候,可能就会碰到下面的超时异常. --------------------------- ---------------------------Timeout expired.  The timeout period elapsed

[bug]Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

写在前面 在mysql中这个异常是非常常见的,超时分为连接超时和执行超时,而连接超时,大部分原因是网络问题,或客户端到服务端的端口问题造成. bug场景 有的时候,使用MySqlDataReader在读取数据的时候,datareader的特性是在在线读取,而且是一条一条往下读,也就是只进式读取.如果数据非常多,就会造成超时的问题. 这种超时是执行超时引起的. SqlCommand.CommandTimeout 获取或设置在终止执行命令的尝试并生成错误之前的等待时间. 等待命令执行的时间(以秒为单

SSRS 2008 R2 错误:Timeout expired. The timeout period

今天遇到了Reporting Services(SQL SERVER 2008 R2)的报表执行异常情况,报表加载数据很长时间都没有响应,最后报"An error occurred within the report server database.  This may be due to a connection failure, timeout or low disk condition within the database.;".检查C:\Program Files\Micro

SQLSERVER:Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

1.Max Pool Size 默认为100. 2.查看当前数据库连接数量, select * from sysprocesses where dbid= db_id('数据库名称') 结果为190, 3.添加数据库查询的最大连接数量 Data Source=.;Initial Catalog=i_Master;Persist Security Info=True;User ID=NUser;Password=N2;max pool size=500设置最大连接数量 500 原文地址:https

SqlException:ConnectionTimeout Expired. The timeout period elapsed during the post-login phase

linux系统部署.netcore程序后,访问某台sqlserver 2008 R2数据库 Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have

Timeout expired 超时时间已到. 达到了最大池大小 错误及Max Pool Size设置

参考数据库链接串: <add key="data" value="server=192.168.1.123; Port=3306; uid=root; pwd=root;database=data;pooling=true;min pool size=5;max pool size=512;connect timeout = 20; "/> 查看应用程序池占用数量: select * from sysprocesses where dbid= db_id

Oracle中的ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

向某个数据库用户中插入.更新.删除一个表的数据,或是增加一个表的主键.索引时,出现下面的错误: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired 这是因为有事务正在进行或是事务已经被锁,因此导致不成功 1)用dba权限的用户查询数据库中有哪些锁 select t2.username,t2.sid,t2.serial#,t2.logon_time from v$locked_object t1

Connection Timeout和Command Timeout

原文:Connection Timeout和Command Timeout 每次对数据库连接时,我们有时候会碰到连接超时或者命令超时,这两个超时是不一样的.以ADO.NET为例,当客户端和服务器端连接时,碰到的超时情况主要有下面几种: 当从连接池获取一个连接时,碰到超时. 当建立一个全新连接(而不是从连接池获取)时,碰到超时. 当发送一个命令(command)到SQL Server时,超时. 当发送命令(连接字符串带有"context connection=true"属性)到SQL S