1. database access performance optimization
A. Minimize database connections and make full use of each database connection: It is overhead to create, open, and close A connection. Available connection pool
B. Rational Use of stored procedures: stored procedures are a set of pre-compiled SQL statements stored on the server. Using Stored Procedures can avoid SQL compilation multiple times, and subsequent queries can reuse previous execution plans. In addition, stored procedures can reduce the network transmission overhead of SQL statements.
C. Optimize SQL statements: This is too much, such as using indexes and views properly to avoid complicated subqueries.
2. String operation performance optimization
A. Use the ToString () method of the Value Type
During the + connection of different types, the boxing operation is converted to the reference type and then added to the string. The boxing operation will allocate a new object in the managed heap and copy the original value to the new object at a high cost. The ToString () method can be used to avoid packing and thus improve performance.
B. Use the StringBuilder class
3. Disable the debugging mode.
4. cache data and page output whenever possible
5. Do not rely on exceptions in the code to control the normal process of the program.
The exception overhead is large. Therefore, use exceptions with caution.
6. Use Page. IsPostBack to avoid unnecessary handling during the round-trip process.
Copy codeThe Code is as follows:
Void Page_Load (Object sender, EventArgs e) // Set up a connection and command
{
If (! Page. IsPostBack) // data is filled during the first loading.
{
String query = "select * from Authors where FirstName like '% JUSTIN % '";
MyCommand. Fill (ds, "Authors ");
MyDataGrid. DataBind ();
}
}
7. If you do not use the session status, you can disable it or set read-only
A. to disable the session Status of A Page, set the EnableSessionState attribute in the @ Page command to false. For example:
Copy codeThe Code is as follows:
<% @ Page EnableSessionState = "false" %>
B. If the Page needs to access session variables, but you do not want to create or modify them, set the EnableSessionState attribute in the @ Page command to ReadOnly.
8. Use mature tools for Performance Testing