1. The law of the WHERE statement
1.1 Avoid using In,not in,or or having in the WHERE clause.
You can use exist and not exist instead of in and not.
You can use table links instead of exist. Having can be replaced by where, if not replaced, can be handled in two steps.
Example
1 SELECT * From ORDERS WHERE customer_name not in2 (SELECT customer_name from CUSTOMER)
Optimization
1 SELECT * From ORDERS WHERE customer_name not exist 2 (SELECT customer_name from CUSTOMER)
1.2 Do not declare numbers in character format, to declare character values in numeric format . (The same date) otherwise invalidates the index, resulting in a full table scan.
Examples use:
SELECT emp.ename, emp.job from emp WHERE emp.empno = 7369; Do not use:
SELECT emp.ename, emp.job from emp WHERE emp.empno = ' 7369 '
2. The rule of the SELECT statement
Restrict the use of select * from table in applications, packages, and procedures.
3. Sorting
Avoid the use of resource-intensive operations, SQL statements with Distinct,union,minus,intersect,order by will start the SQL engine execution, resource-intensive sorting (sort) function. Distinct requires a sort operation, while others need to perform at least two sorting
4. Temporary tables
Careful use of temporal tables can greatly improve system performance
SQL Optimization Records