SQL>alter session set Session_Cached_Cursors=0;
Session altered.
SQL>alter system flush shared_pool;
System altered.
SQL>declare 2 x integer; 3 n number; 4 begin 5 for i in 1..10 loop 6 if i = 1 then 7 x := 5000000; 8 else 9 x := 1; 10 end if; 11 select count(object_id) into n from t where id > x; 12 end loop; 13 end; 14 /
PL/SQL procedure successfully completed.
SQL>select 2 sql_id 3 , child_number 4 , executions 5 , parse_calls 6 , buffer_gets 7 , is_bind_sensitive 8 , is_bind_aware 9 from 10 v$sql 11 where 12 sql_id = ' gp03v5aw085v3';
SQL_ID CHILD_NUMBER EXECUTIONS PARSE_CALLS BUFFER_GETS IS IS --------------- ------------ ---------- ----------- ----------- -- -- gp03v5aw085v3 0 2 3 76405 Y N gp03v5aw085v3 1 8 7 517480 Y Y
SQL>select * from table(dbms_xplan.display_cursor('gp03v5aw085v3',null));
PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------- SQL_ID gp03v5aw085v3, child number 0 ------------------------------------- SELECT COUNT(OBJECT_ID) FROM T WHERE ID > :B1
Plan hash value: 3694077449
------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 4 (100)| | | 1 | SORT AGGREGATE | | 1 | 10 | | | | 2 | TABLE ACCESS BY INDEX ROWID| T | 1 | 10 | 4 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | I | 1 | | 3 (0)| 00:00:01 | -------------------------------------------------------------------------------------
Predicate Information (identified by operation id): ---------------------------------------------------
3 - access("ID">:B1)
SQL_ID gp03v5aw085v3, child number 1 ------------------------------------- SELECT COUNT(OBJECT_ID) FROM T WHERE ID > :B1
Plan hash value: 2966233522
--------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 14373 (100)| | | 1 | SORT AGGREGATE | | 1 | 10 | | | |* 2 | TABLE ACCESS FULL| T | 4999K| 47M| 14373 (2)| 00:02:53 | ---------------------------------------------------------------------------
Predicate Information (identified by operation id): ---------------------------------------------------
2 - filter("ID">:B1)
|