Extraction from zero programming
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. You can use connection pool B to reasonably use 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, the stored procedure 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. When the value type tostring () method is used to connect 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, thus improving the performance.
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.
Void page_load (Object sender, eventargs e) // set up a connection and command {If (! Page. ispostback) // fill in the data only when loading for the first time {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: <% @ page enablesessionstate = "false" %> B. Note that if the page needs to access session variables but does not intend to create or modify them, set the enablesessionstate attribute in the @ page command to readonly.
8. Use mature tools for Performance Testing
References