繫結執行計劃
SQL> create table test as select * from dba_objects;
Table created.
SQL> begin
2 dbms_stats.gather_table_stats('SYS','TEST',cascade=>TRUE,no_invalidate=>false);
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> create index id on test(object_id);
Index created.
QL> select object_name from test where object_id=10;
OBJECT_NAME
--------------------------------------------------------------------------------------------------------------------------------
C_USER#
SQL> select * from table(dbms_xplan.display_cursor());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID f9h894yhsf9bb, child number 0
-------------------------------------
select object_name from test where object_id=10
Plan hash value: 4156516559
------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100)| |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 31 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | ID | 1 | | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=10)
19 rows selected.
SQL> select /*+ full(test) */ object_name from test where object_id=10;
OBJECT_NAME
--------------------------------------------------------------------------------------------------------------------------------
C_USER#
SQL> select * from table(dbms_xplan.display_cursor());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 5wtmgtkv9y21y, child number 0
-------------------------------------
select /*+ full(test) */ object_name from test where object_id=10
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 244 (100)| |
|* 1 | TABLE ACCESS FULL| TEST | 1 | 31 | 244 (1)| 00:00:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"=10)
18 rows selected.
執行coe_load_sql_profile_v2.sql繫結執行計劃
SQL> @coe_load_sql_profile_v2.sql
Parameter 1:
SQL_ID (required)
Enter value for 1: f9h894yhsf9bb
PLAN_HASH_VALUE AVG_ET_SECS
--------------- -----------
4156516559 .004
Parameter 2:
PLAN_HASH_VALUE (required)
SQL>set autotrace on
SQL> select object_name from test where object_id=10;
OBJECT_NAME
--------------------------------------------------------------------------------
C_USER#
Execution Plan
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 31 | 244 (1)| 00:00:03 |
|* 1 | TABLE ACCESS FULL| TEST | 1 | 31 | 244 (1)| 00:00:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"=10)
Note
-----
- SQL profile "coe_f9h894yhsf9bb_1357081020" used for this statement
Statistics
----------------------------------------------------------
34 recursive calls
0 db block gets
1116 consistent gets
1 physical reads
0 redo size
534 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed