Code execution efficiency optimization (1), code execution efficiency optimization
For some systems that need to be reflected in a timely manner, code execution efficiency optimization is particularly important. In combination with the problems encountered today, the following points are described:
1. Avoid nested use of loop statements (for, foreach)
2. Avoid using some exception handling statements (tyr... catch... finally)
3. when you need to perform multiple addition, deletion, modification, and query operations on the database, use StringBuilder to concatenate SQL statements, and try to perform only one addition, deletion, modification, and query operation on the database. This avoids multiple database switch operations.
4. The for execution efficiency is higher than that of foreach.
5. Add related indexes to tables in the database
6. Algorithm Optimization
The above items can be thought of at present, and will be supplemented later.