Problem:
The latest program always throws the following exception:
An exception of type ' System.Data.SqlClient.SqlException ' occurred and is 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) ...
Read Data timeout.
Then went to see the corresponding tables in the database, found that the structure of the table is simple, but the amount of data is very large, there are hundreds of thousands of millions. Look again there is no build indexes/keys, found no, suddenly.
Workaround:
Based on the structure of the table, a Unique key under Indexes/keys isestablished, similar to the following:
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, ALLO W_page_locks = on) on [Primary]go
Test, found much faster and reduced the risk of timeout.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server ...