実行計画の取得、表示

準備

表領域作成
create tablespace test 
datafile '/u01/app/oracle/oradata/orcl/test.dbf' 
size 256m;
テストユーザー作成
create user test
identified by "oracle"
default tablespace users
;
テストユーザーへの権限付与
grant dba to test;
テストテーブル作成
create table test.test
(
  emp_id   varchar2(10)
 ,emp_name varchar2(10)
)
;
テストデータ挿入
begin
  for i in 1..100000 loop
    insert into test.test(emp_id, emp_name) values(i,dbms_random.string('x', 10));
  end loop;
  commit;
end;
/

実行計画取得

実行計画の解析
explain plan for
select emp_id, emp_name
from test.test
where emp_id < 80000
;
実行計画の表示
select * from table(dbms_xplan.display());
表示結果
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1357081020

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      | 97228 |  1329K|   103   (1)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| TEST | 97228 |  1329K|   103   (1)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

   1 - filter(TO_NUMBER("EMP_ID")<80000)

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)

17行が選択されました。