1, Database access performance optimization
A, minimize database connectivity and make the most of each database connection: the creation, opening, and closing of the connection is overhead. You can use connection pooling
B, reasonable use of stored procedures: Stored procedures are stored on the server side of a set of precompiled SQL. Use stored procedures to avoid multiple compilations of SQL, and subsequent queries can reuse previous execution plans. Additionally stored procedures can reduce the network transport overhead of SQL statements
C, optimizing SQL statements: This is too much, such as the rational use of indexes, views, to avoid complex subqueries
2, string operation performance optimization
A, the ToString () method using value types
When a + connection is made to a different type, a boxing operation is converted to a reference type and added to the string. The boxing operation assigns a new object to the managed heap, and the original value is copied to the new object at a high price. Use the ToString () method to avoid boxing, thereby improving performance
B, the use of StringBuilder class
3. Disable Debug mode
4, as long as appropriate, as far as possible to cache data and page output
5, do not rely on the exception in the code to control the normal process
The overhead of the exception is very large. So use exceptions with caution.
6, use Page.IsPostBack to avoid the need to deal with the round-trip process
Copy Code code as follows:
void Page_Load (Object sender, EventArgs e)//Set up a connection and command
{
if (! Page.IsPostBack)////////////////First load
{
String query = "SELECT * from Authors where FirstName like '%justin% '";
Mycommand.fill (ds, "Authors");
Mydatagrid.databind ();
}
}
7. If you do not use session state, you can disable it or set the read-only
A, to disable the session state of a page, set the EnableSessionState property in the @ Page directive to false. For example:
Copy Code code as follows:
<%@ Page enablesessionstate= "false"%>
B, note If the page requires access to session variables, but does not intend to create or modify them, set the EnableSessionState property in the @ Page directive to ReadOnly.
8, the use of sophisticated tools for performance testing