oracle| Performance | optimization
24. Analyze SQL statements with explain plan
EXPLAIN Plan is a good tool for analyzing SQL statements, and it can even parse statements without executing SQL. By analyzing, we can see how Oracle joins tables, how they scan tables (index scans or full table scans), and the index names that are used.
You need to read the results of the analysis from the inside out, from top to bottom. The results of the EXPLAIN plan analysis are arranged in indented format, and the most internal operations will be interpreted first, and if two operations are in the same layer, the minimum operator number will be executed first.
The NESTED loop is a handful of operations that are not handled in accordance with the above rules, and the correct execution path is to check the operations that provide data to the NESTED loop, where the smallest operator number will be processed first.
Translator by:
In practice, it is more convenient to use the Set TRACE function in Sqlplus.
Example:
Sql> List
1 SELECT *
2 from Dept, EMP
3* WHERE Emp.deptno = Dept.deptno
Sql> set Autotrace traceonly/*traceonly can not display execution results * *
Through the above analysis, you can draw the actual implementation steps are:
1. TABLE ACCESS (Full) ' EMP '
2. INDEX (unique SCAN) of ' pk_dept ' (unique)
3. TABLE ACCESS (by INDEX ROWID) of ' DEPT '
4. NESTED LOOPS (joining 1 and 3)
Note: Many third-party tools such as Toad and Oracle's own tools such as OMS SQL Analyze provide extremely convenient explain plan tools. Friends who may like graphical interfaces can choose them.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.