作者:Gemini_2 | 来源:互联网 | 2014-07-09 16:02
Oracle客户端中如何查看执行计划1.执行"explainPlan"语法:SQL>Explainplanforwww.2cto.comTrythiscommand:SQL>explainplanforselect*frommtl_system_items_bwhereinventory
1.执行"explain Plan"
语法:
SQL> Explain plan for
www.2cto.com
Try this command:
SQL> explain plan for select * from mtl_system_items_b where inventory_item_id = 149 and organization_id = 207;
Explained
这个命令会产生执行计划,并把执行计划保存到"PLAN_TABLE"中。
2.查看执行计划
SQL> select * from table(dbms_xplan.display);
(dbms_xplan.display() is a packaged function used to view the execution plan generated.) www.2cto.com
Output like:
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------------
Plan hash value: 780806759
-----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 554 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| MTL_SYSTEM_ITEMS_B | 1 | 554 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 (0)| 00:00:01 | www.2cto.com
-----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("INVENTORY_ITEM_ID"=149 AND "ORGANIZATION_ID"=207)
已选择14行。