C # query timeout of millions of data

Source: Internet
Author: User

When using C # To filter some information from millions of dataProgramThere are many common connection timeout errors, such as timeout expired. The timeout period elapsed prior to completion of the operation or the server.

This article describes several common solutions, which are purely personal opinions.

①: Of course, the first step is to check whether the connection is not closed. Generally, new users will make this mistake. Check it carefully and I will not elaborate on it.

②: If the SQL statement is copied to the query analyzer for execution and the execution time exceeds 30 seconds, the following solution is generally used:

First, analyze the cause of timeout, generally because the connection is not closed or sqlconnection. connectiontimeout times out, And sqlcommand is another type. this method is used to obtain or set the waiting time before the Command Execution Attempt is terminated and an error is generated,

The default value is 30 seconds. You can set it to 0, which indicates no limit, but it is best not to set 0. Otherwise, it will wait infinitely. You only need to query the Time of the analyzer, set this time.

 

③: The execution time is not very long, but the operation still times out. There are also many reasons. There are two common problems: Asp.. NET application requests time out, or the connection life of the connection pool is over. Because the default value of the connection pool is 60 seconds, the two solutions are as follows:

Resolving Application request Timeout:

Add the following statement to Web. config:

<System. Web>

<Httpruntime maxrequestlength = "102400" executiontimeout = "720"/>

</System. Web>

Executiontimeout: maximum time limit allowed for request execution, in seconds
Maxrequestlength: indicates the maximum file upload size supported by ASP. NET. This restriction can be prevented .... Everyone knows .. Haha 

Solve the program pool lifecycle problem:

In the database connection string, modify: Database = AA; uid = sa; Pwd = sa; pooling = true; Max pool size = 1024; min pool size = 1; connection lifetime = 60.

As for the meaning, we can understand the meaning in English... Of course, the min pool size = 1 setting has a lot to pay attention to. If you want to study it, you can see the following in detail:Article, Huh

Http://www.cnblogs.com/ZHUYIN/archive/2011/11/02/2232578.html

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.