SQL optimization suggestion memorandum bitsCN.com
SQL optimization suggestion memorandum
1. SQL comments generally do not increase performance overhead and enhance readability.
2. brief transactions
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 pointing to multiple tables during single-table search
6. DISTINCT and order by overhead
It can be processed in the application.
7. try to set the default value for each column, 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 query to avoid type conversion
9. create an index for the columns associated with the foreign key
10. UNION and union all have higher efficiency.
11. INSERT statements
Insert into table VALUES (...) Performance is worse than insert into table (...) VALUES (...)
12. notes for using ORDER
Any non-index item or calculation expression in order by will reduce the query efficiency.
13. Balance BETWEEN and IN
...
BitsCN.com