SQL optimization suggestion Memorandum 1. SQL comments generally do not increase performance overhead, and can enhance readability 2. The transaction should be brief www.2cto.com 3. Avoid cursor operations because the cursor occupies a large amount of resources 4. Balance between IN and EXISTS 5. Avoid nested views and avoid it during single table search the overhead of view 6, DISTINCT, and order by pointing to multiple tables can be processed in the application. 7. Set the default value for each column as much as possible, and not null. Because columns containing NULL values cannot use indexes, even if you create an index. Queries that use is null and is not null do NOT use indexes 8. Massive queries avoid type conversion 9. Create indexes for columns associated with foreign keys 10. UNION and union all, the latter is more efficient. 11. insert into table VALUES (...) Performance is worse than insert into table (...) VALUES (...) 12. Notes when using order by any non-index item or Calculation Expression in order by will reduce query efficiency 13. Balance BETWEEN and IN...