You are on page 1of 24

 

 

$  !$&! 
&!!$"!$&! -($&! - $! -
karen.morton@method-r.com

 *))+()*()+



  
 
!"


!"!  
 

    & '  
$
  
  
   !
! 
    




 ! 

$  "  
 
    !   

#
 
 

 
$
  

% 
  !



# !
   
 
$  #  

 

!

#"
! 



$

!     
 $#'$+!"&,$%&!"&)& & $$ &&%$%"! %!$&$  &!"&
*'&! " !$
/!"&,$'%&$()+!'$#'$+&*& &$&!($'&"!"$&! !%&&
)!'"$!(&$#'$$%'&%&/% $! $&%!%&('&&&!"&,$& '%%&!!"$
&!!&$% $!!%&%/!%&% %&&('&&% & &!"$!"!$&! &!&*"&$%!'$
'% &!*'&&%&& &)&"$&'$" /!"&,$'&%!%&!%%"&% ! 
!$$%%!  %&&!& !"'&$$%!'$%-) '%2 - - !$+/8 
*'&! " %&! )&&!)%&%&&!%&/

!!  
$$ + !$&!  "'&% &!&!"&,$1%'&! %- ' .!&%&&%&%-%+%&%&&%&%-
"$&$%&& %- "+%% !%3//-"$&&!  -'%&$ -  * 4/'&%&&%&%$&
"$$+ !$&! %!'$!$&!"&,$/&%&$!'&'%!%&&%&%&&&!"&,$&&"&%&!
&$ &!%& &)+&!'%$%!'$%&!%&%++!'$#'$+/!$'$&++!'$%&&%&%$&
&&$' &'$!+!'$&-&&&$&!"&,$5%" !)- &'%&&&$+!'$#'$+
"$!$ )/

!" 
"!$& !%&&%&%%( & &%'&! %'%+&!"&,$/
&1%&%"

%&& & $&!) %&!"&,$)!'&!$()&"$&%&&%&%"+ &$(&! !&
*'&! " /
SELECT *
FROM ord
WHERE order_no = 256769;


%&&%&%!$&ord&$.


8 $&% $!$ '  '88%8-"/880:

6977; &!!$"!$&! /$&%$%$(/ 8


Statistic Current value
--------------- ----------------------
# rows 12890
Blocks 180
Empty blocks 0
Avg space 0
Chain Ct 0
Avg Row Len 79
Degree 1
Sample Size 12890
Partitioned NO
Temporary N
Row movement DISABLED
Monitoring YES

  order_no  '


# distinct values: 12890
Sample Size : 12890
Nulls : N
# Nulls : 0
Density : .000078
Avg Length : 5
Histogram Info : NONE
Low Value : 66
High Value : 999969

! &%"!$ $ ( !$


 "   (        "
 "( # &!$" order_no = 256769(
!$
     $ 1/NDV,0!  - ,- WHERE ($ &
   ! ,     "-&  $ 
"!$     $( # &$(111178
2+23891(
!  &% "  
 
   (    $# 
" $  ( $ $!$$ " (
cardinality = selectivity  # rows in table
 # " '(111178.23891:2(11653(
%" "!",-  " ( 
!  #&    $ ,$ * - 
" % (
 " % $,    !21164%
 -'
   )
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 79 | 42 (3)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| ORD | 1 | 79 | 42 (3)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
1 - filter("ORDER_NO"=256769)


3         /3119  (!(
!'&&,%"*(&!!!+1
---------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 79 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| ORD | 1 | 79 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | ORD _PK | 1 | | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("ORDER_NO"=256769)


"'"*'"#' -%4&&' '"&'"%'!+&&#!7=8&"!&%,"*%'!'&' '"&'"%
'('&!#!7?=80"(!&"*' &&!&'''&' '"&'&&&"%!!+&!.&(&!
!!+'"&&'&' '"!%"**%'!,'"'*%"&&&'!('&!*"(0
)!'''!+#!&'"*%"&'.*!"!('''"#' -%*"(""&''+('"!#!"%
'$(%,0
!&"".  
  
7#%&&.=;;@8. "!'!
*&#%")&!!2#')*""*'
5"#' -%'%&'"!',"!)%',"(%$(%,!'"!+('"!#!06"% ( "%'""'"*'
"#' -%" #('&"&'!'% !&$(%,+('"!#!&'!*")%%.,%" !'&""0
'2*,%" '&%+ #&'''"#' -%%&),"!&''&'&!""&!!+('"!#!0
'"#' -%"!&%&&''&'& #"%'!'.'!&"&"(,"(0

  
 
"*.'4&'%""'' "%'"('+('"!&#!&0&4)%,&''.'+('"!#!"%
$(%,&'%&('!&'""#%'"!&'"" #'&"!'"#' -%4&" #(''"!&"%'%!'
&!%"&#"&&''*"(%)'%&('&'"%'$(%,0!'"%)*''(+('"!#!&"%
,"(%$(%&&!!)('"""%'% !!"*,"(%$(%,&#%"% !!"%&&&'!!!"&!
#%"% !#%" &0"*)%. !,#"#"!(&'"('#('"EXPLAIN PLAN*'!+('"!#!0&!
EXPLAIN PLAN"!,#%")&,"(*''#!''5&"(6+('0'&!&' '0'4&',#,)%,""
&' '.(''"!,*,'"''+'+('"!#!"%$(%,&'"+(''$(%,!#'(%''(
#!'0!"EXPLAIN PLAN&!& %'"'%!'*!'!&" "*"*,"(4'%"*
&!'(,"!'0"( ,'"" .('!,"('(,"+',*',"(&,3
'(+('"!#!&!'%&''&'&!#'(%!&)%*,&0*""' "&'" "!%7<8(&!
+'!
'%!7=8%'%)!'&'+('"!'"%$(%,%" V$SQL_PLAN"%'&%')*&0!
%)%&"!<;!"). %#%")&!&,'"(&#(!'"!.dbms_xplan.display_cursor.'"
%'(%!!,"% ''#!''!(&+('"!&''&'&0
+(''""*!+ #!
9(&.(&!'& #$(%,&"*!%%/
SQL>set serveroutput off
SQL>select /*+ gather_plan_statistics */ * from ord where order_no = 256769 ;

ORDER_NO CUST_NO ORDER_DAT TOTAL_ORDER_PRICE DELIVER_D DELIVER PA EMP_NO DELIVER_NAME ...


---------- ---------- --------- ----------------- --------- ------- -- ---------- ------------- ...
256769 19314 28-APR-03 42232.66 28-OCT-04 By Noon CC 9875 XFPFMFCXR ...
SQL>
SQL>select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------
SQL_ID 34rzzvhjq0r8w, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from ord where order_no = 256769

Plan hash value: 3958543594


-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |

:=;;A '""%#"%'"!0%'&%&%)0 >


| 1 | TABLE ACCESS BY INDEX ROWID| ORD | 1 | 1 | 1 |00:00:00.01 | 3 |
|* 2 | INDEX UNIQUE SCAN | ORD _PK | 1 | 1 | 1 |00:00:00.01 | 2 |
-------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("ORDER_NO"=256769)


""#"#"!#""!&+  """"# %!# &#"!""!"!0""3!
"""A-Rows)A-Time)Buffers#!1)'##!"" #!"gather_plan_statistics"
'# # ' '##!"!""statistics_level " "ALL+#!""!!!#!$!"'
"! %!# &#"!""!"! "# ''#- "!"+'#" " )""!"!
 " # !&#""" "!!! !'!"$)%'#!!#" " 
)#""! !"0"#"$#!TYPICAL1+'!""" " "ALL)'#'#  " 
$   "'"'#% !'"" "# ',',# '!!+
!""""!&!%!"#!"set serveroutput off+!!!"""!
" 2
#!"!# """&#"""!!'!"!"# '&#"""
 "&#""dbms_xplan.display_cursor#"+"%"!serveroutput!*
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------
SQL_ID 9babjv8yq8ru3, child number 0

BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;

NOTE: cannot fetch plan for SQL_ID: 9babjv8yq8ru3, CHILD_NUMBER: 0


Please verify value of SQL_ID and CHILD_NUMBER;
It could also be that the plan is no longer in cursor cache (check v$sql_plan)


"dbms_xplan.display_cursor#"!'!"" "!"&#"!""")'#"#'
!"!""""DBMS_OUTPUT"!"!"""%serveroutput!+ )#!"  "" 
2
#!)'#!#!"serveroutput !"+
'#$"&#"")'#3$"%" ""'#" "" #  
# '+'""!!'  $"#!Starts)E-Rows)A-Rows)A-Time)Buffers+
Starts
# "!" "# !"!&#"+!"""!"!6)#""!NESTED LOOPS
%!#  ")'#%'! # +
E-Rows
#  %!""" # '"( 
 %# "# ' %!#  "
"+!!" "'#"""!" "  +
A-Rows
"##  %!""    "# ' %!#  ""+
A-Time
"#!# "  "+""" "!"!#"# "!" 
!"!+
Buffers
"##"!! "!## !"# 0!%!.  "! 
 !1+""" "!"!#"# !!#"!" !"!+

!#"' ""#""! "!""'#""!&"'%"'# # '+"-!"#!!+
"-!" &#" " '# # '+!!$##!"!%!'#! "'#
#!%'# # '!!$+  """$'"  !%"
!!%/ &)%" -!$##""-!#!99:" %!"+!%-!#!!


8         47559"   "+ "! ! $+
$!#!#"#*($!#E-Rows$%$#A-Rows$%$!
"##"'#(&!($%!!!"$("&#,#$!'*#E-
Rows$"&8*$##A-Rows$"&:*<89/!##)!5""##
#$!#(%$""%%#!&($%"&($!#,


     



##"$#!#*#0"#&#$""","#%!(&!#"$#!#*
"*1#"#"##!#"##"#"/2"&!"+#",#!&!"
"&!##&!!%!(
!&$0%"$!(##(&,*"&("*($"(##

!"$"###,
!%!"87*"##"#"#&"$#####$""#!
($#
!"$""##"#"#&%!#"($87>,
$!"*($
"#""$$###!""*("#$"###,$#
!
!!#0"##&"#!%##!""#(!"##"$####",

!"$####"##"#"##!""##(!!"##%##$
###",
####! $!(!!"5##((##!#&!#!",
!
#)!"("
##%"##"#"&#((!%!!#"##!!!"#$%(#
!%!!#!#$,##*#(%#!##"##"#"#!""!%
!"$#!"#",9 $!"##$#"#"""$#&! $!"####
!"##"#" $!(#'##&##)!#!%#,
!#"+

##"#"##0#!"("!($!#$#3,,*$"#(0!"#!""4
-#!!#("##"*
-&"#!""#"#*
-&"#!#"#*
-&"#!!!"#*
-&"#! '$##",

##"#"##!. *&#!($!#"&($&#""#!($!%!#/

 
    

#"##"#"##"*$"*'",!!"%!%&"3"##"#
!4##'""##"#"#3#"%&""%
!'%!""4,

dba_tables dba_tab_cols
dba_tab_statistics dba_tab_columns
dba_tab_histograms dba_tab_col_statistics
dba_tab_partitions dba_tab_subpartitions
dba_indexes dba_ind_columns
dba_part_col_statistics dba_part_col_statistics
dba_ind_partitions dba_ind_subpartitions


9     
    

 ,
!
!977;,

6977= # !!#,!#"!"!%, ;


##"#"!#$##(( !!($###)!"##"#"$($"#
DBMS_STATS, !!"!($##"##"#"$##(*$#"#
! $!#"##!##"#!#"##($%#'$#$(,!"
###!"!!)*(#($!#0""(",

  


 

$###)!"##"#"##!"#)!"##"#"(#

   !$!,"!$!#""##"#"#"#"&#
#"!%$"(#!"##"#"!#'"#"##"#"!"#$"#$!(#"
"#(3!#87=#!&"4,
   "#!
!$!*$##!#"%!("!"##
 !$!$"#
GATHER AUTO#,!!(!"###$##('$#!$!!!#)"##"
#"##! $!"##"#"*"###"#"##"#$#"##"#"!!""!"#,""$!"
###"#."##"#"!#!!##&&"",:
#"!#######$##!$!!#"##"#"""#$#&#"#
"&#!#!#,($!#"!(*$"($!"##"#"#"##
#&#&&"*#($&#"!$##!#%", !"$"#"##
%##"#"#"##%!$"!(#"!$#",
#!!####!!"##$"#$"#0"$##"0##&"#$!#(
#"$"($!#",('!*0%$###$####"!
#$"#" $#$#!#$! $!("#!$#"#"""$""#(!!%##(
!#!"#","!#" $"#"+
• "#!($!$"!"##"&#!!!""!#(#!($$#($!"##"#"/
• "!!!87=#3$##!!$###4$!"/
• &%$"!$"#(#&$###"/
• "($!#!!"1""#%2#$"!$#""&"#%$"/
"!$"#&# $"#"($#"($!"##!$###"$"
"$""$(($!%!#,($"&!("#!!#" $"#"*#$##"##"#"
#(#"!%($"&",

  
 
 
"!%$"("##*#$##"##"#"#&#!!#"(87=#!&"!
!*"##!#, #!!*#&!$$!#'#!#&&
3#!"#&&(4, $%##*$(*&$'$#!
5
$""&"+
SQL> exec DBMS_STATS.GATHER_TABLE_STATS ( ownname=>?, tabname=>?);

#!&!"*#!#"(#&!#*##!!#!"&$$"$#%$",
"$#"!+
partname NULL cascade DBMS_STATS.AUTO_CASCADE
estimate_percent DBMS_STATS.AUTO_SAMPLE_SIZE stattab NULL
block_sample FALSE statid NULL
method_opt FOR ALL COLUMNS SIZE AUTO statown NULL
degree 1 or value based on number of CPUs and initialization parameters force FALSE
granularity AUTO (value is based on partitioning type) no_invalidate DBMS_STATS.AUTO_INVALIDATE

###"#($"## !&-
• #&###"""##"#(1$2estimate_percent%$3"&!#&,777778
8774*

: !#"
!!$$88 "8*,8:.9,


;         6977<# !!#,!#"!"!%,
• !" !! ! " ! ! $! 172! !"!
#" $!!"182!$1 !&SYS.COL_USAGE$2'
• !$!% !! ! !!!1!  " "&TRUE2'
• !$!!!#!!"  1!  " "&TRUE2*
" !!&' 4!!,
' !,!!!!!! !! !! !&
."*/"&#! !! ! $!!"!$!!!
!$!'#-!*9 !4 "" " '&"! &'!!4 
%!&&!*  !! !&."/"&",!- !!!%
! !& !*:! $ $!- "!#"'METHOD_OPT=>FOR ALL
COLUMNS SIZE AUTO'"  *




 
! !!$!$ *! !" )a'b'c*"a'!&&' "!
&rownum, !&"& !"!* ."/!!" !"!! !"'!- 
! "!#"!!)$ !$$!#"7'666'666'666*"b "&
 !"!$!#" !$776(" !!%!& &!  !
"* &'$ &!!"c  "& !"!'"! . /!!! &
 !!#"*
SQL>desc auto_test
Name Null? Type
----------------------- -------- -------
A NOT NULL NUMBER
B NUMBER
C NUMBER

Statistic Current value


--------------- ------------------------------
# rows 1000000
Blocks 2260
Empty blocks 0
Avg space 0
Chain Ct 0
Avg Row Len 10
Degree 1
Sample Size 1000000
Last analyzed 2009-01-27 16:40:59
Partitioned NO
IOT type
Temporary N
Row movement DISABLED
Monitoring YES

---------- Column Statistics ----------

Column NDV Sample Size Nulls # Nulls Density Avg Len Histogram Low Value High Value
------- -------- ------------ ----- -------- --------- ------- --------- ---------- -----------
A 1000000 1000000 N 0 .000001 5 NONE (1) 1 1000000000
B 10 1000000 Y 0 .100000 3 NONE (1) 1 10
C 1 1000000 Y 0 1.000000 3 NONE (1) 100 100

---------- Index Statistics ----------

Leaf Distinct Num Clust Avg Leaf Avg Data


Index Name Col# Column Unique? Height Blks Keys Rows Factor Blks/Key Blks/Key
----------- ----- ------- ------- ------ ---- -------- -------- ------ -------- --------
SYS_C007131 1 A Y 3 2087 1000000 1000000 2202 1 1


9&*!!)00$$$*&**

: "! ! !%"! "! " - !

!!)00!*$ *0866<0670690 3 !! +!3!+"!+#"+++76++"0*

5866= ! !*!  #* ;


! !$"!!! !! ! ! %"!"&!#$!!', )
1* 1006!$! ! *  ! ! $ !#METHOD_OPT !!FOR ALL COLUMNS SIZE
1-! $ ! 5"!.*
2* 1006!" !SIZE AUTO !!*  ! ! $ !#METHOD_OPT !!FOR
ALL COLUMNS SIZE AUTO-!  ! 10#"!.*
3* 1006!! !&"*  ! ! $ !#METHOD_OPT !!FOR
COLUMNS a SIZE 254-!  "! "&.*

! !"&  ! $ $!#""a !!1(000(000)


select /*+ gather_plan_statistics */ * from auto_test where a > 1000000;

   
  
$!!"a !& !"!%!!$$!#!"!#"*
(!"&$!"&1$*  !!!!$"!(
!" !&&%"a!!#! $*
  
  
Test 1 (100%, FOR ALL COLUMNS SIZE 1)
SQL>select /*+ gather_plan_statistics */ * from auto_test where a > 1000000;

A B C
--------------- --------------- ---------------
1000000000 1 100

1 row selected.

SQL>select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------
SQL_ID 2614vs0sn81cp, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from auto_test where a > 1000000

Plan hash value: 3800464057


-----------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-----------------------------------------------------------------------------------------
|* 1 | TABLE ACCESS FULL| AUTO_TEST | 1 | 999K| 1 |00:00:00.05 | 2237 |
-----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
1 - filter("A">1000000)

!!%!$ !" 555(!1!!! %"!"! *&+" 


!!'!"!!! !#"!" 1(000(000(000!$#" 1($&"
 $ $!a > 1000000(!"!!!&! )
cardinality = (High value - predicate value) / (High value - Low value) x # rows in table
! "(!!,  !#!&*555*"!&! !#!&&!"$ !!-1.
!&"#&"555 !!*"!$! &$!! !  ""&*  
""!#"* !' ,!" !!  #"* !'$ !!!!!"&
$!"555$ #!""!"! ,!$!! !&* ",!!!'$
!!+!,  " SIZE AUTO$*
Test 2 (100%, FOR ALL COLUMNS SIZE AUTO)
SQL>select /*+ gather_plan_statistics */ * from auto_test where a > 1000000;


4         /2005!
!*!  #*
A B C
--------------- --------------- ---------------
1000000000 1 100

1 row selected.

SQL>select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------
SQL_ID 2614vs0sn81cp, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from auto_test where a > 1000000

Plan hash value: 3800464057


-----------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-----------------------------------------------------------------------------------------
|* 1 | TABLE ACCESS FULL| AUTO_TEST | 1 | 999K| 1 |00:00:00.05 | 2237 |
-----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
1 - filter("A">1000000)

 % SIZE AUTO$  #   b 
c ' a(!#*  )%  !!!
! $    #  !AUTO
METHOD_OPT%!$'   #! a 
    "  %
Test 3 (100%, FOR COLUMNS A SIZE 254)
SQL>select /*+ gather_plan_statistics */ * from auto_test where a > 1000000;

A B C
--------------- --------------- ---------------
1000000000 1 100

1 row selected.

SQL>select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------
SQL_ID 2614vs0sn81cp, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from auto_test where a > 1000000

Plan hash value: 1106764748


--------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
--------------------------------------------------------------------------------------------------------------
| 1 | TABLE ACCESS BY INDEX ROWID| AUTO_TEST | 1 | 3937 | 1 |00:00:00.01 | 4 | 2 |
|* 2 | INDEX RANGE SCAN | SYS_C007131 | 1 | 3937 | 1 |00:00:00.01 | 3 | 2 |
--------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("A">1000000)

 !$  '!      
" %

#   # 


 &   
 METHOD_OPT    #%

+-,,.  % % .


    
 
!("'"!&"&''&'&*%'!"% (!' %<;4&('" '"!& "!'"'&!0"()"#
,"(%"*!&%#'&!&'(#%(%,&("&'""'(#'&''&'&0".'"''! %'
")%!&'"#(&!,"(%"*!.
 '"&&!%!'"#'! # !'0"( ,)
'(, !'' #'."!,'")#%" &%&(&,'!*"'"!('&.!&","(4)%'(%!
'","(%" '"&0
('" '"'"!&'"#' -%'" #!"&'')#""%#%"% !!,"(%!)%"! !'.'&
#%',%&"!'""'"'5'%!'%(6 '"&0$(&'"!,"( (&'(' ',!&*%&/*'&
'&'*,'""'&''&'&! ,!)%"! !'3  %'''('" '"'"!&(&(')(&
''  &(!'"% !)%"! !'& "'' 0 '" &"*!'"*'% "&'"'' &
""!"("%,"(0
 
   
 


"*","(*')(&'"(&"%')%"(&"'"!#% '%&,"(!''('" '"'"!&
"!4'*"%"%,"(3 "#,"(%!&*%&/'&'.'&'.'&'0!"%'(!',.'%&#"!& '*! &"*
#%'(%&'%',*&&'&.51*'%'!'(&'*"%.&"*&'(*''06
0 &(##"&'''
%&('&%*',"(*!'.'!#%#&5""(&&6&'%',*"%8!'&&90('.*',"(*!''" 
!('(&&)%&(&&"'2!2'2%(&&3
!('(&&%$(%&,"('""'!%!&*%&'"*,$(&'"!&/
• '%' "&'" "!$(%,#%'&"%,'&3
• &'#"&&'")#"#(%)(&"%"!"% "%"( !&!,'&3
• &'#"&&"%')(&'"!"!2(!"% ,&'%('8%  %"(%"('%+ #%" %%93
• ","(%'&)#!!'"( !&&('',"(&#,%$(&'"%)(%" "!"( !.,"(%,
"!4'!'"'%"!'"'%"( !&'*"(#%"('& %&('3
• &'"%!" ,."%!&#"%%3
&&&&''"","('(,)'%,#%&!'0 ,"(4%'%,!'"'% !"'"!&'%',
*'"('%'!%(!'"(%',!&*%'&$(&'"!&.,"(4%,"!'"(&'&*")%'"
(&('" '"'"!&0)!,"('!,"(!!&*%'$(&'"!&*'&" )""!!.#%#%
'"(&',"(%#!")%' ,"(%!&*%&*%5"06

    


!"'%&''&'&"'"!"#'"!'' !,#"#"'!"!4'"!&%&!,'! "%'!' #"%%,+&
,! & #!0,! & #!"(%&*!&''&'&% &&!"%!"'0"%+ #."'&''&'&
,!"'+&'"%!*,%'"'&8#%'(%,"%!*,%'#%''"!&9"%"%' #"%%,"'&0'"('
&''&'&.'"&'2&"#' -%&!$('!0"%'%'!(&&8(&(')(&9.'"#' -%*
'' #''""'&" &''&'&(%!'$(%,"#' -'"!#%"&&0
"'"!''"(%&'$(%,"#' -'"!' #!&"!'&''!"%'OPTIMIZER_DYNAMIC_SAMPLING
#% '%"%&"!'% !,'#%&!"'DYNAMIC_SAMPLING$(%,!'"%#%'(%'0
%%<<)&''!&8)(&!'%!;7<;9"%,! & #!!! %<;!").'&''!
('&'"=0&''!";!'&!"& #!&'""!!&''!"<;!'&'"& #"&!'
'0&''!&'*!;!<;!'!%&!& #&-&!*%%&'%'"!&"!*!,! 
& #!"(%&0
('&''!"=&5""!"(6'" &(% ! & #&"'*!&''&'&"!4'+&'.('
")!(#'")">)&,"( (''%")%.#%'(%,*!,"()"%%'#%'&8* 4
&(&& "%'%90')>.'"'"!*"(%"%!,(!!,-'(''*&"&')',
&' '&"%#%'&'%%!="% "%"( !&%" '& '0 '4&'""'!+ #''
&"*&+',*''&)"& #! !&'"'"#' -%4&','"#%"#%,('%"*&' '&0
%&'.*4%''''&'*""( !&.c1!c2.''%(%!''"*,&"!'!'& )(0


<;
         :=;;? '""%#"%'"!0%'&%&%)0
SQL>create table depend_test as
2 select mod(num, 100) c1, mod(num, 100) c2, mod(num, 75) c3, mod(num, 30) c4
3 from (select level num from dual connect by level <= 10001);

Table created.

%!)    0//5   '


SQL>exec dbms_stats.gather_table_stats( user, 'depend_test', estimate_percent => null, method_opt => 'for all columns size 1');

PL/SQL procedure successfully completed.

"%!)" #!  c1 !" #0//!'


SQL>set autotrace traceonly explain
SQL>select count(*) from depend_test where c1 = 10;

Execution Plan
----------------------------------------------------------
Plan hash value: 3984367388
----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 8 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
|* 2 | TABLE ACCESS FULL| DEPEND_TEST | 100 | 300 | 8 (0)| 00:00:01 |
----------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - filter("C1"=10)

 ! '!%)## * c2' 


   %#!" #0//!'%! $
(
SQL>select count(*) from depend_test where c1 = 10 and c2 = 10;

Execution Plan
----------------------------------------------------------
Plan hash value: 3984367388
----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 6 | 8 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 6 | | |
|* 2 | TABLE ACCESS FULL| DEPEND_TEST | 1 | 6 | 8 (0)| 00:00:01 |
----------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - filter("C1"=10 AND "C2"=10)

!%!   '! ')!0&0//'


 $% # %
   ' # %  %
$ #! ##  '

  #  AND 
cardinality = (selectivity c1)  (selectivity c2)  # rows in table
% %    #'/0,0*0/-%  # 0'
!%)## dynamic_sampling  3'   /+2% 
)  3%)   '

SQL>select /*+ dynamic_sampling (4) */ count(*) from depend_test where c1 = 10 and c2 = 10;

Execution Plan
----------------------------------------------------------
Plan hash value: 3984367388

.1//4 ' ' 00


| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 6 | 8 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 6 | | |
|* 2 | TABLE ACCESS FULL| DEPEND_TEST | 100 | 600 | 8 (0)| 00:00:01 |
----------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - filter("C1"=10 AND "C2"=10)

Note
-----
- dynamic sampling used for this statement

#)!."!&""##"&!!#- "#"#&""#"&($$"##!#("##""$+
"#"&&#"$###)!." $!("+#$$"##)!
#"!!#""#"!!"$"($#$&#$"% $!"+
%3(""##""&!$###)!!($!"##
!#!!#+ #*&%!*##$"#dynamic_sampling###(
""#!#!!#"#"#+$#*##"#"!!"##%#%!($.#!##)!
##"%!!""&#!($"#"##%$"#,&!# $!(,(, $!(""+
($.!&#$"("*"$!#!$("!&#!($&# $!"#
'"#("!($(&##"(!# $!"(##+
!#"($!($"
!11!&%!($$!*($%!#&#'#
"##"#"+$!#'#"##"#"##"!#!!##&$"###)!+"#
$"("%3#""#!#$"10*($&$"#!$!
dbms_stats.create_extended_stats#!#!%"##"#"$#$"+
SQL> select dbms_stats.create_extended_stats(ownname=>user,
2 tabname => 'DEPEND_TEST', extension => '(c1, c2)' ) AS c1_c2_correlation
3 from dual ;

C1_C2_CORRELATION
--------------------------------------------------------------------------------
SYS_STUF3GLKIOP5F4B0BTTCFTMX0W

SQL> exec dbms_stats.gather_table_stats( user, 'depend_test');

PL/SQL procedure successfully completed.

SQL> set autotrace traceonly explain


SQL> select count(*) from depend_test where c1 = 10 and c2 = 10;

Execution Plan
----------------------------------------------------------
Plan hash value: 3984367388
----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 6 | 9 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 6 | | |
|* 2 | TABLE ACCESS FULL| DEPEND_TEST | 100 | 600 | 9 (0)| 00:00:01 |
----------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - filter("C1"=10 AND "C2"=10)


("('##!#%#$"##"#"#"+ !($("$#'#!
%!!#""##$!##!!"# $!(+($"##"#!#!
"## $!"%$(*##($(##!!#""#
#!%!( $!(##"'$#+"($"#%!( $!(&$$"("+ #."

12
         /2004# !!#+!#"!"!%+
*,'& #"%'!''"'&'!)%,'!'&!%" !%&!',! & #!)/%&"(%&
!'""'& #!*"% , "%")%'! ,!&&%,"%&%/

  
    
 
!"'% '""%#%")!'"#' -%*'&''&'&&'" !(,&'')(&/
! ,+#%!. !,
#"#&#!"%%"%''#%"&#'"&''!&''&'&' &)&/.!"'"!,&'#"&&.'1&$('&,'""
*''dbms_stats#%"(%&set_column_stats.set_index_stats.!set_table_stats/#%)!
'!!&''%*"''%"+('!"% "'"!!&" "*"(% !(&''!&*&&
(%'/%.#%#&'1&(&''&%'"'"#"!''!%'%&''&'&%23/')%'
%&"!.,"(&"(!"*''&''&'&%!"'' ",%/"(!'"(!!' &,"(*&!'1&
%, /)!%&(##"%'&'''&#%',%&"!'"&'&''&'& !(,! '!!"'8<>9>=/8
4%" *,!977:5/
&'%&"!'"&'&''&'& !(,&'"#%")(%'!(%%!')(&"%&" "'&'"'"#' -%
*'"(')!'"(%!'%&"(%&'"%(!"'"!/"%+ #.'1&&,'',"((&'"< "!%"*&
!'"'!,"(!"*%" '"#%"&&'+'"(!'&!&'%('"!")(&*'!,"( !&"%'
!*'/,!"' ",'&''&'&"%'''%',!!"'!(%'+#!&""!
gather_table_stats#%"(%0

%%' &*!'"'"!#%"&&.)!,"("''877@.*!"'#!''#%',"%%'#'(%"
,"(%'/" "! &"!#'"!&''877@"'"!&&"(2#%'/3&&!1'!&&%,'%(/
!+
(&'%!'"%&"!&''&'''!"''877@!(&#!&''%'"',*%"!/(&'%!'"%
& &(%""**"%%''&&" #%'"'!+"%%!&(&'"#'"#' -%
'% !&' '"&&&/
'1&&,'''%*%"!,*"&!,"(%'(''%"*&!!&%'!'"'&"&!&(
*,''!&%'&*% "!!'%!'!&&/
!"'%*"%&.%"*8*&!&%'!"877.%"*9*&
!&%'!"878.%"*:*&!&%'!"877.%"*;*&!&%'!"878.!&""!/

  
    

"*84 &5  "*94%"*!5
"*:4"5  "*;4)&5
"*<4% %5  "*=4 !&5

"*.%'!!+!!"'"*'"%%"!'%&&'&'%!'!#''%!!"%''*!''*"
"&/

    
 & "877"*8
%"*! "878"*9
" "877"*:
)& "878"*;
% % "877"*<
!& "878"*=

(%!&''&'&"'"!.'!+(&'%!'"%&(',!'rowid"%)(!!
'""(!'*!)%'"!( %!&/
!"(%&!%".'"!( %*!"%)%,)(/&
(&&'(&'%!'"%'")%,/!(&'%!'"%&.'"#' -%*"&''(&"''
!+"%%!&! (%'!'&"((&'*" #(''' !,. !,%!'"&*!
'"&&/('''%('&''"!,'*""&%,!'")&'/
"(!''"#' -%'2%'%('3, !(,&''!'(&'%!'"%"%''!+,"(%&/"(1!
'""' "%*"%'"'% !'&'&''!.(',"!&"'"#' -%*)''%'*'*'"
''%"'"(&'!+*!' ,)"&!'")"'!+"'%*&/

6977? '""%#"%'"!/%'&%&%)/ 8:


 0%$*(*# &*$%%$%%$%$.
& %# $! #%%% * &#%  ) #!%
!%+# %$% %! $$*% #')&% !$ #* &#"&#$.

 
   
  
%%$%$%% 0%&#%*#!#$%* &#%&%#%# %&$ #*  !# #
!# $.$%%$%$#$% # /)$%%,$#!#$%%%&$%% * &#%,% !%+#
!# !# $ #)&% ! !#% $.  $ (# &$% !%+#0% !&%
&#% &#%*$%%$.
0'#* %%( !# $$(#$%%$%$ 0%!# !#*#!#$%%%.#'(
)!(# &%#'&%%($0% #*# +%$%%$%$%&$% !%+#% &$
&%$()$( &0'%%# .$ $( (% !%+#$$&$%%
!#%$#!%$!%  !&%% ##%#%*(&%! &$# ##%
%  %#.
%0$ %%# %##$(# /#!#$%%'$%%$%$&$!# $-
• %$(
• !
•  ##% ('&$%%$%$

 
*&%,% !%+#$$&$%%%'&$ # &#& #*$%#&%.$ $%$$%#&,%
!%+##*&#% !&%%  %!#% # ($ %'&. #)!,
%##8$%%'&$ #% &  #%##544# #$%%,$(0'#*$,
% !%+#( !&%%%##$$ (  #* &($% $%,69# ($(#%&#11/4  100 =
252.

 ('#,%'&$ # &# %& #*$%#&%,% !%+#(&% &#%* !&%


 (*# ($%''&. ##% %%&% $ ##%,% !%+#$% '$% #
$%%$% #$& &$.
 & %$% #$&$%METHOD_OPT!#%# %$%%$%$%#!# &#$.
!# !#* %,%$%'%* #''&$ #&#%.$$!)!&$%$%%&%&$
%ALL_OBJECTS'(&$%#%$*! %.% %$!!# )%*5.: # ($) %
object_type &.%%$%$(# %%544=(% $% #$%object_type &$7:
$%%'&$.#$%"&#*0$!#%(%$% #%#'# ($(#%object_type='PROCEDURE',%
$ "&#*(%$% #%#'# ($(#%object_type='SYNONYM'.
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------
SQL_ID 16yy3p8sstr28, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ owner, object_name, object_type, object_id, status from
obj_tab where object_type = 'PROCEDURE'

Plan hash value: 2862749165


------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
------------------------------------------------------------------------------------------------------
| 1 | TABLE ACCESS BY INDEX ROWID| OBJ_TAB | 1 | 44497 | 2720 |00:00:00.06 | 1237 |
|* 2 | INDEX RANGE SCAN | OBJ_TYPE_IDX | 1 | 44497 | 2720 |00:00:00.02 | 193 |
------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("OBJECT_TYPE"='PROCEDURE')

%%#%(%E-RowsA-Rows'&$. !%+#&%%%88,8<;# ($( &


#%&#$ %!#$%%% &'&$(#& #*$%#&%.$ %$#$&%,%%&


58
         3644<
%   #! #% .#%$#$#'.
  

+/

#"
"
! 
 


  

#

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------
SQL_ID 9u6ppkh5mhr8v, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ owner, object_name, object_type, object_id, status from obj_tab
where object_type = 'SYNONYM'

Plan hash value: 2862749165

---------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
---------------------------------------------------------------------------------------------------------------
| 1 | TABLE ACCESS BY INDEX ROWID| OBJ_TAB | 1 | 44497 | 640K|00:00:14.25 | 104K| 19721 |
|* 2 | INDEX RANGE SCAN | OBJ_TYPE_IDX | 1 | 44497 | 640K|00:00:04.52 | 44082 | 1696 |
---------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - access("OBJECT_TYPE"='SYNONYM')

  
"

'
 &  (" 

  

+-#

!   " 

 
  #"
 
! 

 object_type 
  

    

%&  

" 
SIZE AUTOMETHOD_OPT
 

#
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------
SQL_ID 16yy3p8sstr28, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ owner, object_name, object_type, object_id, status from obj_tab
where object_type = 'PROCEDURE'

Plan hash value: 2862749165


---------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
---------------------------------------------------------------------------------------------------------------
| 1 | TABLE ACCESS BY INDEX ROWID| OBJ_TAB | 1 | 2720 | 2720 |00:00:00.07 | 1237 | 29 |
|* 2 | INDEX RANGE SCAN | OBJ_TYPE_IDX | 1 | 2720 | 2720 |00:00:00.02 | 193 | 0 |
---------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("OBJECT_TYPE"='PROCEDURE')

$ 

# !  
" 

 #

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------
SQL_ID 9u6ppkh5mhr8v, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ owner, object_name, object_type, object_id, status
from obj_tab where object_type = 'SYNONYM'

Plan hash value: 2748991475


------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
------------------------------------------------------------------------------------------------
|* 1 | TABLE ACCESS FULL| OBJ_TAB | 1 | 640K| 640K|00:00:03.36 | 64263 | 21184 |
------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
1 - filter("OBJECT_TYPE"='SYNONYM')


    #
& " !






 
# 
      


),**0 
# # +.
#!&$%).$%),%"&#*% 9<.:=$ $% )&%% #98<,888
&#$.%%$% #!% % &$&%$,%"&#*)&% %# !!% ;.;>
$ $ *><,:>;&#$$$.
$* &$,(% !%+#$%$%%$%$,%$% %%#! $%%'* &%
!# #* &(%. &# $% $&#* &!# '% !%+#(%(%%$.%
$* &%  (* &#%( &%  (( &$*)!#$( %$% #$
% $ &$.
 &#$,* &(*$%
#%#( &$$% #$*&$%
METHOD_OPT=>SIZE AUTO !% .&$%##%  #
#2$$ $$%* &# ( ( %
%  #$$&$% &%#'&!# (#'(##.


  

#?,% !%+#$% 3!4%%'&$ %'#$&$* &#"&#*
&#%#!#$!$. # #% '#$ ?,
# %'&$&%%#%!$ 
#*.%%$%($%%* & %$% #$%&$'#$% 
%#* &#"&#*,% !%+#( &&$&%$%'%*'& #% &&% &$%
$% #.* &% &%%,%$$$.%#'& &#)! '($$%%
$% #% %#%$!$%'%* #%%'&.&%,% !%+#2% (%'&%!#$%,
%% 3&$$4%%$%'%*.&$$$&$&*' #%&$ )$%&%&$$($=@
$%'%*.
&%,$ '#$ ?,% !%+#$%'& %'#$%  !&%$%'%*$%(#
 $%#.$$ % % %/$ / %.%2$ ' &$* &$( (%
!%+#(% &$%& &$%%$%$% %#%$%! .&%,(#% $(# $
)%*%$!% $#%0
%2$&$ &#!#' &$)!.#$%,$$&%"&#*$)&%(%'#$% %#%
'#$$%% PROCEDURE.$$ &'&$%$!$( %(&$%%#5)$6.
&%,%!#  $((#&%$"&#*$ %$%%'#% SYNONYM.% 
* &(%% !%+#%  1
%"&#*$%,)!% #%'#'&,% !%+#( %%%!%% #!#$%"&#*
$ %.$%,%(#%#'%!#' &$*$%!&$%% 5..,%( $ %!#$6. 
%$% #!&$($)$ !#% ,%%2$(%(&$% )&% &##"&$%% #%#'SYNONYM
# ($.,$('#*$,%)$$'#*! #!# # %%$.
$$(#'#$#&$ # &$(%& #*$%#&%'&$,%! ( &2%
(%#%'&$.!# $(%!#!##*#%%  &$(%$(
%%%#"&#$% #$% !# !#! $$ $!'&$. ($$%%
#
'#$ 99,%%&#$ #$#$'.$%&# ($&#$ #$&$'#$%! $$%* 
%%(!$(% &'&$.
"&#*)&%$%% %$!#% !#$( &5..,%$$% #6% 
'#%(5  #$( &'&  # /$('&6,%"&#*$#$
$$%'. &$%$ %% %is_bind_sensitive & v$sql. %!#$ %$% #
%$%%% &$$(,#%'&$ %'#* ##%!$.
% % $$%'%*,%#$  %#(%&#%% $% %!%&#-/(#&#$ #$.
&#$ #$(#("&#*$)&%(%%( #%'&$%%$ &#"&##%!5
&#!#' &$)!, ( &)$% %#( &&%$6.$"&#$)&%,

# % #$%' # %"&#$%#$(%##%'&$&$%%' &$
!&%*%"&#*% $%*#%.$ ,
#!%$%$' #$ %%%$!$ %
(*$$# #%$"&#*.$% #&$% #!,(!$#%$ %&##%
'& #$&$"&%)&% $.

#'#$ 99,($ (%%&#$ #$#$!# '$% ##%! # %
'#'&$(%$($!#$%.$)!, &#%$()! '# 
#98,&$$
%$%%&%&$%ALL_OBJECTS'((%!!# )%*:.9 # ($) %object_type


9>
         7:88? %   #! #% .#%$#$#'.

 
  

  #""'   object_type
      
 object_type='PROCEDURE'   
        object_type='SYNONYM' 
           
    PROCEDURE   
 
   SYNONYM
SQL> variable objtype varchar2(19)
SQL> exec :objtype := 'PROCEDURE';

PL/SQL procedure successfully completed.

SQL> select /*+ gather_plan_statistics */ count(*) ct


2 from big_tab
3 where object_type = :objtype ;

CT
---------------
4416

1 row selected.

SQL>
SQL> select * from table(dbms_xplan.display_cursor('211078a9adzak',0,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
---------------------------------------
SQL_ID 211078a9adzak, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ count(*) ct from big_tab where
object_type = :objtype

Plan hash value: 154074842


-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-----------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.03 | 16 |
|* 2 | INDEX RANGE SCAN| BIG_OBJTYPE_IDX | 1 | 4416 | 4416 |00:00:00.01 | 16 |
-----------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("OBJECT_TYPE"=:OBJTYPE)

SQL> select child_number, executions, buffer_gets, is_bind_sensitive, is_bind_aware, is_shareable


2 from v$sql where sql_id = '211078a9adzak' ;

CHILD_NUMBER EXECUTIONS BUFFER_GETS IS_BIND_SENSITIVE IS_BIND_AWARE IS_SHAREABLE


--------------- --------------- --------------- ----------------- --------------- ---------------
0 1 16 N N Y

SQL> exec :objtype := 'SYNONYM';

PL/SQL procedure successfully completed.

SQL>
SQL> select /*+ gather_plan_statistics */ count(*) ct
2 from big_tab
3 where object_type = :objtype ;

CT
---------------
854176

1 row selected.

SQL>
SQL> select * from table(dbms_xplan.display_cursor('211078a9adzak',0,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
---------------------------------------
SQL_ID 211078a9adzak, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ count(*) ct from big_tab where object_type = :objtype

!$""&       #%


Plan hash value: 154074842

-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-----------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:04.33 | 2263 |
|* 2 | INDEX RANGE SCAN| BIG_OBJTYPE_IDX | 1 | 4416 | 854K|00:00:01.71 | 2263 |
-----------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("OBJECT_TYPE"=:OBJTYPE)

SQL> select child_number, executions, buffer_gets, is_bind_sensitive, is_bind_aware, is_shareable


2 from v$sql where sql_id = '211078a9adzak' ;

CHILD_NUMBER EXECUTIONS BUFFER_GETS IS_BIND_SENSITIVE IS_BIND_AWARE IS_SHAREABLE


--------------- --------------- --------------- ----------------- --------------- ---------------
0 2 2279 Y N Y

1 row selected.

    ! 


  


#    "

  ,",)-
 

!#
  )-
*"*-+#
    "

!
  #$  !



  
%SYNONYM&#

SQL> select /*+ gather_plan_statistics */ count(*) ct


2 from big_tab
3 where object_type = :objtype ;

CT
---------------
854176

1 row selected.

SQL>
SQL> select * from table(dbms_xplan.display_cursor('211078a9adzak',1,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
---------------------------------------
SQL_ID 211078a9adzak, child number 1
-------------------------------------
select /*+ gather_plan_statistics */ count(*) ct from big_tab where
object_type = :objtype

Plan hash value: 1315022418


---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
---------------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:04.44 | 6016 |
|* 2 | INDEX FAST FULL SCAN| BIG_OBJTYPE_IDX | 1 | 854K| 854K|00:00:01.85 | 6016 |
---------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - filter("OBJECT_TYPE"=:OBJTYPE)

SQL> select child_number, executions, buffer_gets, is_bind_sensitive, is_bind_aware, is_shareable


2 from v$sql where sql_id = '211078a9adzak' ;

CHILD_NUMBER EXECUTIONS BUFFER_GETS IS_BIND_SENSITIVE IS_BIND_AWARE IS_SHAREABLE


--------------- --------------- --------------- ----------------- --------------- ---------------
0 2 2279 Y N N
1 1 6016 Y Y Y

2 rows selected.


).
         '*((/  
# #

%$  ! )"  *  &!    
     ! &     )-*      &

  !  ! !   ! &
 '  &
 
    !    !      % 
 ! &!%!      &
!%!" #!      %!"     &
%         %!  (

SQL> exec :objtype := 'PROCEDURE';

PL/SQL procedure successfully completed.

SQL>
SQL> select /*+ gather_plan_statistics */ count(*) ct
2 from big_tab
3 where object_type = :objtype ;

CT
---------------
4416

1 row selected.

SQL>
SQL> select * from table(dbms_xplan.display_cursor('211078a9adzak',2,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
---------------------------------------
SQL_ID 211078a9adzak, child number 2
-------------------------------------
select /*+ gather_plan_statistics */ count(*) ct from big_tab where
object_type = :objtype

Plan hash value: 154074842


-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-----------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.04 | 16 |
|* 2 | INDEX RANGE SCAN| BIG_OBJTYPE_IDX | 1 | 4416 | 4416 |00:00:00.02 | 16 |
-----------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------
2 - access("OBJECT_TYPE"=:OBJTYPE)

SQL>
SQL> select child_number, executions, buffer_gets, is_bind_sensitive, is_bind_aware
2 from v$sql where sql_id = '211078a9adzak';

CHILD_NUMBER EXECUTIONS BUFFER_GETS IS_BIND_SENSITIVE IS_BIND_AWARE IS_SHAREABLE


--------------- --------------- --------------- ----------------- --------------- ---------------
0 2 2279 Y N N
1 1 6016 Y Y Y
2 1 16 Y Y Y

3 rows selected.

 ! ! !  "   &  ..   
   ! !  %$   !  
%  #  +  #&    %!   !&
 !   " %! ! %  
  &
!       &
 !  
 !  % ! " &

,/--0  & & .0


'  "##$#&'$
"&"#55,+$#$"$#$$"#+)%%#)
$$ #0$")#$$#$###%,-$0###%,$)%$$&"#55+)%0$
#%"$ " "))%" $#$%$"$$# ,)%''$&%#"
#'+)%)#$$$$$#$#"$'#'&%#".#$#
$"#$)%" ,$&%#0$$$##'+)%0# )"$ #$$$$$%##
&",)$$ #$%"#$$&%#$$)#',$%"#'+
$".#%0$"$$)%!%%"#"#$#" ,$%"#+)%0&$
'$#$&)%!%%"#"#$#" 1$##$&"$" "#
$&$)2#$$$&$ $*"$#$ " " ""$&%#,

 
  
  
'&%#$$#$#"%"%#$ $*"0#%$#"$"#$&$)""
"$#,"( +$"#'&%4&%54"colx)%#"'"colx > 8+
$ %$$'
selectivity = (high value – colx value) / (high value - low value)
"#$&$);,6,""+$$544"'#+$ $*"'%#$$$$64"'#1,6:5442'%
"$%",#""%'%$)%#"colx < 8, %$$'
selectivity = (colx value – low value) / (high value – low value)
"#$&$);,8,""+%""#%$"'#$$'%84"'#1,8:5442,

%"#+$""$" "$"#$#"#%#<;"=;,+0"$$)%"$'#0
  
  
1 "##+64472"%"$$"$$$#%$#,
$0)%$%"#$#'$ #)%(%$!%")$$%## "$%$#$"$
'$&%#$$#$#,$"'"#+'$)%"#$$#$#$%$""$'%
&%#/ "#$$$ $*"0#"$)#$$'$%"$)" "#$$%""$$,
) )+$$#$#$$'$',"( +&$'$544+444"'#%")
#$"%$"&%#%colx$'958,!%")%$#$#"$"#+
"'
 %$$#$&$)#$)"$",!%")"'"colx < 8+$ %$$'
selectivity = ((colx value – low value) / (high value – low value) + 1)  .10 
"#$&$);,488889,""+%""#%$"'#$$'%8889"'#1,488889:544+4442,
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------
SQL_ID 9fah3fcf24nx5, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ count(a) from hi_lo_t where b < 8

Plan hash value: 3460024886

------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | INDEX RANGE SCAN| HILO_B_IDX | 1 | 8889 | 0 |00:00:00.01 | 2 |
------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - access("B"<8)

$"#$$$$%$$#%$#$$#$&%colx&#"$"')"$$%
'1"2&%+$"$)#$$&#$'"5,$# $+#$#$$$##"#"+
$#%#$ $*"$&")"$#%$$(%$ + "$%")"$$$#
"",


64
         36449 $ " "$,"$#"#"&,
!&& !!&"!$#" !! ! "!)
$#(&""! &"*#!& !"!!! !! ! $
!)
   !!"&!$!!!! $!! !! ! !
!!!"&" !)  *# !!"  " $!!" 
$$!! ! !! ! !#" !!)!  !
!(! !! !  "!" !$!#" !!$&!) ! !!!
low_value(high_value(num_distinct(! !! ! !!!& !!!
!$!!)!! *!(!! !! ! !(!!'##&
!!!%"!)! !" (&  &!!
!  " &!& !! !! ! "&)
! $   $ !! ! !" METHOD_OPT!! *!!
" !! ! " )%(&" METHOD_OPT=>'FOR ALL INDEXED COLUMNS'(&
!! ! %" $!)&"!" "!! *!%"&(!!'
 "!!" "!+" ,!!"*  !! ! )
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------
SQL_ID 6nawp6qk6yqcy, child number 1
-------------------------------------
select /*+ gather_plan_statistics */ count(a) from hi_lo_t where b = 12

Plan hash value: 3307858660

----------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
----------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.07 | 184 |
|* 2 | TABLE ACCESS FULL| HI_LO_T | 1 | 1000 | 10000 |00:00:00.05 | 184 |
----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - filter("B"=12)

! %("B*!#%! !! ! $!!$" 


METHOD_OPT=>'FOR ALL INDEXED COLUMNS') (!!'" "!25)(! !!!
!' *!# !!#!"!!! &$)
 !!"!!$#" !! !  $ !!" !! ! -
num_distinct(num_nulls(num_buckets-!!!!!'* !&! !!%"!
 !!" ! #" " !!'!"!!& !! !! 
!"!!!") "!!!& !! (!&! !!!
!'$ !$ !) "" !"& &" !! ! !
 ! "!&#!!'$!! ! !!#!"&"!  )

       
  
 !! ! ! !!( &$! &! (!"!!
"(&"!!! !) !($ !! ! ! *! !!&!"!!
 +$!!(!$( $" !#!!!$&,) "#$ (! !!#
 !!# !! !  " !&"$!&"! ! !$)
  * "!!!  !! !  !"(!  ! !!$!$!
!   !.))(" "!!!!" /" ! !)  
"! !#! # 22!"!&"!!!  $ !

03114!
!)!  #) 32
 $"!""""!"""+7
 !% "#'""! " ,
#""!#"+%$ )'"!!#!%-$!#!!   !"'# $ "/++)"
!%)#" $#!)" "!0)"'#%"  !#"#"! 
#!""!""!"!"$ "!!"#"!+# !)" -!%'!'!"
!%+

      


   
-$ $ ""!""'!!&"" "$"" 
 , ## !) "# '%""!"!# !  $!! !"!""!"!#"
 #"'+ ' !)    )%!#"&#"!'!"!"! 
#  "!"%" !+ '!% "" #!$ !" 
  !# ")8! "!"!!%"$  !!"
#!"% "
$ "!+  % $ !!!&#"# 6 "$ "! !+ "%! !
%!!"" !"% ""% #!"" $!""!"! !"#!''
!"$6$ !#!$322;"%""optimizer_dynamic_sampling " !""6+ 
%"!%!" !""% #!%" !!"!/""
0$ $ 7
&#"! !!+


%!$ '!"!%%#!''!  ) "# '" !$ !+ 
""") #5)""#!''!)$ """!"
" !!


7!"  "( +  
        
    # '44)4229+

""*.."( +!"+.4229.23. $",,#",!,!""!"!+"


8 '-!  !""$ #"""*.."+. !+


44
         1422:"   "+ "! ! $+
+('"!&''*%&&'!(!>''(&;::C"'"!1%,(&!'"!#'")%!&
#%"% !!'"%1!*'&''&'&#,!&(,%"!'"#' -%4&','"'% !'&'
+('"!#!&

  '!",!&'"!%'*,'" "!'"%"**,"(%&''&'&)%
"!&&'!'#!#%"% !1!"*'',"(!4'%*!')"!(&"!%" &!'&'&'&"!.
('"'!'&#&)%,,""**,! & #!!*"%1

    


'!'&'&''&'& ! !'&'%',&"'! ''%"& #,
"!'!&''&',"((#"%
#%" &1,"("!&%'%&*%&''&'&!"*%"!&*4)&(&&%.'"''" 2!&"!
" ," #!,4&)"%'&,!&.5,  *!,"(!
6
&'""*!&&'"*'
'""0
• "!4'(&&*,,"(4%(%%!',(&!'&''&'&&'%',,"(%/!"('1#%&"!*""%!,%'
' '"!(&"%&''&'&"'"! ,!"')!'%!, "%1!"('!"'"!,*'&!"!.
('*,.!"( !'''"%"(,1
• "!4' !,!&'","(%&''&'&"'"!#%"&&*'"(''"%"('&'!1&#%'(%,##&'"
(#%! %)%&"!&1  %''('" '&''&'&"'"!"#'"!&!*')%&"!1
• "!4'*'',"()#%" &'"""',"(%&''&'&1)*'&''&'&'%"'"!." #%
#%)"(&)(&'"(%%!')(&.! "!'"%%&#"!&' &!)%!&"%'&',&(&'","(%
##'"!4& "&'" "!$(%&1'%'!! %;:1<1:1>'DBMS_STATS#"!'!&&'"
(!'"!&! DIFF_TABLE_STATS_*''!(&'"#%"(%!%#"%'&'*!%!'&'&"
&''&'&1,"(4%(&!!%%)%&"!.,"(4)'"*%',"(%"*!1
• "!4'!"%,"(%'1""&''&'&"'"!&'%'&%"(!"!'"%"(!"*","(%'1
!%&'!!'&'%('"!&!"*'& "&'" "!,$(%*#,"( "!'"%,(&' !'
%&711."'&''!&#'%' !'81
"''''&&!"'&'"' &'"#('"!,"(%'"2"&'1'4&!'!'"&'")"%&'',"(
""&'" # !'' .,"(4! "%&(&&! !!&''&'&!,"(%!)%"! !'1"!4''!,"!""
,"(3%&!"&!&'%',''*"%&&'"%)%,"!1 %&"!'&&''"#%")('" '&''&'&
"'"!"#'"!&''")% "&'" "!!)%"! !'& "&'"'' 1('.;::C&"('"!7"%'&'&"&
'";::C&,"(!'8!"!,%)*'%(&'(,!'&'!"!,"(%#%'1

 

)' %"#' -%& %'#,%!'% !!"**,"(%##'"!*#%"% 1%%
!,'"(#"!'&!' %'&''.!"' !#%"#%,.!'"#%"% !"''!&1('
,"(%##'"!&%,"!''!'%" ''&!'4&'"#' -%4&"'""!*'"#%'"!&*
(&'")%''''","(1"(%!"*"('"*'"#' -%(&&&''&'&."*%!'
&''&'&"'"! '"&"'!'''"#' -%*(&.!"**,"(!"*,"(%"*!'.
" !'"#%")'"(!'"!"&'!"!&&'!'##'"!#%"% !1
%"!'!(&'" #%")('" ' !& &"%"'!&''&'&!"*'"#' -%(&&'&''&'&
'"#%"("#' +('"!#!&1('('" '#%"&&&%&'!'','""''''"%%',
#!'&" #'#'(%","(%'!&&1 %!',"(?:C.@:C.A:C."% "%"'*,'"*%&
!"#' "'"!.''4&'''%1% !!#%'"'"(%!,&(#'","(3
''&##%."#)( !''""*!,#"!'&"%,"(0
• ''&'&''%&"!,%#%&!',"(%'('%%''"'"#' -%4&','"'% !&'!
"!&&'!',#%"% !+('"!#!&"%,"(%##'"! 1
• !%&'!!&"#' -%&''&'&" #(''"!&#&,"('% !*!&''&'&%5""6"%516
• %4&('" '&''&'&"'"! '"&%!'!'"#%")&''&',5""!"(6!"% '"!
"% "&'!)%"! !'& "&'"'' 1

9<::B
'""%#"%'"!1%'&%&%)1 <=
• %%&''&'&%''"'&*."('%'.#%'#!!,.!"'%&.*%('" '
"'"!&(&!('"#'"!&"!"'#%")*''"#' -%!&'""%%','% !'"#' 
+('"!#!0
• ,! & #!#%")&&''&'&'"'"#' -%*!!"!+&'.*!&''&'&%&'."%*!
#!!'#%'&+&'0
• !(,&''!"( !&''&'&"*&#%&"!'%"")%&#&''&')(&*'"('%$(%!'
%&"(%('-'"!"("'"!0
• &'!! "!'"%!"&''&'&&"(!!'%#%'","(%##'"!#%"% !%)*&0
• !"*!,"(%'&%''"&!!,"(%&''&'&"'"!! ! !'&'%',0
"#'&##%!"(%&,"('"%! "%"('"*'%"#' -%*"%&."*&''&'&''
"#' -%2&','"#%"("#' +('"!#!&."**,"(!"*,"(%'.!"*,"(!(&'&
!"*'"%'&'%',"%&''&'& ! !'''&&'"%,"(0

   

""'.%0 ,  , $#%!/.+!$(
''#/55%%""'0*"%#%&&0" 5><<D5<=5<@5 &9&''&1 '"9"#'1('1)"(%1!1!1=<11
%(50
!&'%#' -%"0
 !%# " "##"#"#!#$! !//0
!(%,
>>.><<D0''#/55"#' -% 0"&#"'0" 5><<D5<=5 #%") !'1"1('"1& #!1&''&'&0' 0
*&.
"!'!0"#)" !$#"0%,./#%&&.><<B0
!&.",!0
$"#!!-" !#  !#""0#%0
''#/55"#' 0" 5##%&5   '0#0
!&.",!0"!"' "$!!$"# !!0%&!''"!0
''#/55"#' 0" 5##%&5 ##%""%0#0
%"%#"%'"!0 !#" !!$$//"/0><<D0
''#/55"*!"0"%0" 5"&55>D?AE9<=5&%)%0===5>D>C@5'"0' 0
60 !# !# #&!##"#" !#"/.0%#!"%><<A0
''#/55***0"%0" 5'!"",5#",5#%"% !5#59EB=9>C?EB=9=<B1=9 9)>0#0

     
%! "%'"!'&##'"!"#' -'"!'"" #!&%"(!'*"%.!"'&&%"" &''!&!
&"(%1'"1&"(%"!&('!! !'&0&'%'"%"('"!!&%)&"% '""%#"%'"!
7## '**#)!(8."('.+&" #!,"(!,%, &#0 '""%&"!&('!&%)&.
('"!"(%&&.!&"'*%'""&6!(!' '"%"%6''#,"("#' -,"(%&"'*%
#%"% !0
"%")%><,%&. %!&*"%!!"% '"!'!"",&'%'!"('& !% #%"% %.)"#%.
.'%''!!"*&%&%%.('"%!"!&('!'0)!(&%&!'%,E<:&.&
!'!"'%&"*'"(&%")%"0
&%$(!'&#%'"!%!&!(&%%"(#&.!%.!  %"''*"%7!
!"% &&"'"!"3%&!'&'&4''%*!"*!'%"("(''%" (!',80"&'
''#/55%! "%'"!0"&#"'0" 0


>@
         ;><<E '""%#"%'"!0%'&%&%)0

You might also like