Explain Plan in Oracle
Explain Plan in Oracle
--====================================================
HOW to Generate EXPLAIN PLAN and
how to read and understand
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_supplier_sites_all
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A, ap_supplier_sites_all B
where A.VENDOR_ID = B.VENDOR_ID
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A, ap_supplier_sites_all B
where A.VENDOR_ID = B.VENDOR_ID and
org_id = 82
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A, ap_supplier_sites_all B
where A.VENDOR_ID = B.VENDOR_ID
and org_id = 82
and A.vendor_id = 1
select * from table(dbms_xplan.display('sys.plan_table$'));
--==================================================================
OUTPUT
--==================================================================
Plan hash value: 3410715412
select * from ap_suppliers A
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 372K| 98M| 4037 (2)| 00:00:01 |
| 1 | TABLE ACCESS STORAGE FULL| AP_SUPPLIERS | 372K| 98M| 4037 (2)| 00:00:01 |
------------------------------------------------------------------------------------------
Plan hash value: 3644361572
select * from ap_supplier_sites_all
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 371K| 132M| 5046 (1)| 00:00:01 |
| 1 | TABLE ACCESS STORAGE FULL| AP_SUPPLIER_SITES_ALL | 371K| 132M| 5046 (1)| 00:00:01 |
---------------------------------------------------------------------------------------------------
Plan hash value: 1704517579
select * from ap_suppliers A, ap_supplier_sites_all B where A.VENDOR_ID = B.VENDOR_ID
------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 371K| 231M| | 20991 (1)| 00:00:01 |
|* 1 | HASH JOIN | | 371K| 231M| 102M| 20991 (1)| 00:00:01 |
| 2 | TABLE ACCESS STORAGE FULL| AP_SUPPLIERS | 372K| 98M| | 4037 (2)| 00:00:01 |
| 3 | TABLE ACCESS STORAGE FULL| AP_SUPPLIER_SITES_ALL | 371K| 132M| | 5046 (1)| 00:00:01 |
------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."VENDOR_ID"="B"."VENDOR_ID")
Plan hash value: 3540612086
select * from ap_suppliers A, ap_supplier_sites_all B where A.VENDOR_ID = B.VENDOR_ID and B.org_id = 82
-------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 61967 | 38M| | 15310 (1)| 00:00:01 |
|* 1 | HASH JOIN | | 61967 | 38M| 22M| 15310 (1)| 00:00:01 |
| 2 | JOIN FILTER CREATE | :BF0000 | 61967 | 22M| | 5033 (1)| 00:00:01 |
|* 3 | TABLE ACCESS STORAGE FULL| AP_SUPPLIER_SITES_ALL | 61967 | 22M| | 5033 (1)| 00:00:01 |
| 4 | JOIN FILTER USE | :BF0000 | 372K| 98M| | 4037 (2)| 00:00:01 |
|* 5 | TABLE ACCESS STORAGE FULL| AP_SUPPLIERS | 372K| 98M| | 4037 (2)| 00:00:01 |
-------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."VENDOR_ID"="B"."VENDOR_ID")
3 - storage("ORG_ID"=82)
filter("ORG_ID"=82)
5 - storage(SYS_OP_BLOOM_FILTER(:BF0000,"A"."VENDOR_ID"))
filter(SYS_OP_BLOOM_FILTER(:BF0000,"A"."VENDOR_ID"))
Plan hash value: 569357530
select * from ap_suppliers A, ap_supplier_sites_all B where A.VENDOR_ID = B.VENDOR_ID and org_id = 82 and A.vendor_id = 1
--------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 653 | 6 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 1 | 653 | 6 (0)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID | AP_SUPPLIERS | 1 | 278 | 3 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN | AP_SUPPLIERS_U1 | 1 | | 2 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID BATCHED| AP_SUPPLIER_SITES_ALL | 1 | 375 | 3 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | AP_SUPPLIER_SITES_U2 | 1 | | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("A"."VENDOR_ID"=1)
5 - access("B"."VENDOR_ID"=1 AND "ORG_ID"=82)
filter("ORG_ID"=82)
--====================================================
HOW to Generate EXPLAIN PLAN and
how to read and understand
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_supplier_sites_all
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A, ap_supplier_sites_all B
where A.VENDOR_ID = B.VENDOR_ID
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A, ap_supplier_sites_all B
where A.VENDOR_ID = B.VENDOR_ID and
org_id = 82
select * from table(dbms_xplan.display('sys.plan_table$'));
--====================================================
explain plan into sys.plan_table$ for
select * from ap_suppliers A, ap_supplier_sites_all B
where A.VENDOR_ID = B.VENDOR_ID
and org_id = 82
and A.vendor_id = 1
select * from table(dbms_xplan.display('sys.plan_table$'));
--==================================================================
OUTPUT
--==================================================================
Plan hash value: 3410715412
select * from ap_suppliers A
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 372K| 98M| 4037 (2)| 00:00:01 |
| 1 | TABLE ACCESS STORAGE FULL| AP_SUPPLIERS | 372K| 98M| 4037 (2)| 00:00:01 |
------------------------------------------------------------------------------------------
Plan hash value: 3644361572
select * from ap_supplier_sites_all
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 371K| 132M| 5046 (1)| 00:00:01 |
| 1 | TABLE ACCESS STORAGE FULL| AP_SUPPLIER_SITES_ALL | 371K| 132M| 5046 (1)| 00:00:01 |
---------------------------------------------------------------------------------------------------
Plan hash value: 1704517579
select * from ap_suppliers A, ap_supplier_sites_all B where A.VENDOR_ID = B.VENDOR_ID
------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 371K| 231M| | 20991 (1)| 00:00:01 |
|* 1 | HASH JOIN | | 371K| 231M| 102M| 20991 (1)| 00:00:01 |
| 2 | TABLE ACCESS STORAGE FULL| AP_SUPPLIERS | 372K| 98M| | 4037 (2)| 00:00:01 |
| 3 | TABLE ACCESS STORAGE FULL| AP_SUPPLIER_SITES_ALL | 371K| 132M| | 5046 (1)| 00:00:01 |
------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."VENDOR_ID"="B"."VENDOR_ID")
Plan hash value: 3540612086
select * from ap_suppliers A, ap_supplier_sites_all B where A.VENDOR_ID = B.VENDOR_ID and B.org_id = 82
-------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 61967 | 38M| | 15310 (1)| 00:00:01 |
|* 1 | HASH JOIN | | 61967 | 38M| 22M| 15310 (1)| 00:00:01 |
| 2 | JOIN FILTER CREATE | :BF0000 | 61967 | 22M| | 5033 (1)| 00:00:01 |
|* 3 | TABLE ACCESS STORAGE FULL| AP_SUPPLIER_SITES_ALL | 61967 | 22M| | 5033 (1)| 00:00:01 |
| 4 | JOIN FILTER USE | :BF0000 | 372K| 98M| | 4037 (2)| 00:00:01 |
|* 5 | TABLE ACCESS STORAGE FULL| AP_SUPPLIERS | 372K| 98M| | 4037 (2)| 00:00:01 |
-------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."VENDOR_ID"="B"."VENDOR_ID")
3 - storage("ORG_ID"=82)
filter("ORG_ID"=82)
5 - storage(SYS_OP_BLOOM_FILTER(:BF0000,"A"."VENDOR_ID"))
filter(SYS_OP_BLOOM_FILTER(:BF0000,"A"."VENDOR_ID"))
Plan hash value: 569357530
select * from ap_suppliers A, ap_supplier_sites_all B where A.VENDOR_ID = B.VENDOR_ID and org_id = 82 and A.vendor_id = 1
--------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 653 | 6 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 1 | 653 | 6 (0)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID | AP_SUPPLIERS | 1 | 278 | 3 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN | AP_SUPPLIERS_U1 | 1 | | 2 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID BATCHED| AP_SUPPLIER_SITES_ALL | 1 | 375 | 3 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | AP_SUPPLIER_SITES_U2 | 1 | | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("A"."VENDOR_ID"=1)
5 - access("B"."VENDOR_ID"=1 AND "ORG_ID"=82)
filter("ORG_ID"=82)
Comments
Post a Comment