oracle performance optimization

SQL optimization:
    1. Tables with less data should be placed at the end of from.

    2. The order of links in the where clause. The where clause is parsed from the bottom up, and the conditions for filtering a large number of records should be placed at the end of the sentence.

    3. Select avoids the use of * and reduces the use of subqueries.

    4. When designing the table, set the index column to not null, avoid using not, is null and is not null on the index column, using wildcards ('_', '%') in the index column is invalid, and avoid changing the type of the index column .

    5. Use in to replace or, use exists to replace in, use not exists or external link instead of not in.

    6. Try not to use <>, != and wildcards ('_', '%'), use >= to replace >, and where to replace having.

    7. Replace distinct with exists.

    8. Replace or with (union) union all (for indexed columns).

    9. Replace UNION with UNION-ALL (if possible):
When a SQL statement needs to UNION two query result sets, the two result sets are merged in a UNION-ALL manner, and then sorted before outputting the final result . If UNION ALL is used instead of UNION, then sorting is not necessary. Efficiency will be improved. It should be noted that UNION ALL will repeatedly output the same records in the two result sets. Therefore, you still need to use UNION from business requirements analysis The feasibility of ALL. UNION will sort the result set, and this operation will use the SORT_AREA_SIZE memory. The optimization of this memory is also very important.

    10. The order by statement is loaded on the index column, preferably on the primary key.

    11. The sql statement should be capitalized (oracle parses the statement, first convert it to uppercase) 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326350125&siteId=291194637