檢視執行計劃方法總結之一:explain plan命令

Frank_dba發表於2014-04-10
檢視執行計劃的方法有很多種,筆者今後將在部落格裡一一為大家介紹。本文介紹的是第一種方法,利用explain plan命令來檢視執行計劃。

1.用hr使用者登入資料庫
[oracle@ENMOEDU ~]$ sqlplus hr/oracle@ENMOEDU 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 10 00:11:00 2014
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

HR@ENMOEDU > 


2.使用explain plan命令
HR@ENMOEDU > explain plan for select salary from employees where first_name like 'Pat';

Explained.

3.檢視執行計劃
HR@ENMOEDU > select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------
Plan hash value: 3033625502
-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |     1 |    11 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| EMPLOYEES   |     1 |    11 |     2   (0)| 00:00:01 |
|*  2 |   INDEX SKIP SCAN           | EMP_NAME_IX |     1 |       |     1   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - access("FIRST_NAME"='Pat')
       filter("FIRST_NAME"='Pat')

15 rows selected.


至此,執行計劃檢視成功。

Frank

2014.04.09

--To be continued--
































來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29436907/viewspace-1139098/,如需轉載,請註明出處,否則將追究法律責任。

相關文章