flashback snapshot of schema

Upload: sumit-kasana

Post on 06-Jul-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/17/2019 Flashback Snapshot of Schema

    1/49

    Flashback Snapshot of Schema

    Few days ago, one of my clients performed a "drop" action occidentally on the website. But he could not confirm what he dropped is correct or not. He want to see thescreen before he dropped the items.

     The first thought we got is to utilize flashback query. Howeer, this simple actionactually deleted important data from many tables !oer #$, and the code of displayingthe i is fairly comple%. Flashback query doesn&t help in this case. 'e finally e%portedentire schema using e%pdp with flashback(time option, and imported it to a testenironment.

    ) eer thought if oracle proided a session parameter flashback(scn*flashback(time toallow the user flashback query all of data to a specified scn*timestamp in the session,it will make things simple. 'hat we need to do is to create a new connection, andchange this parameter after connected to database.

    Then ) was thinking can ) find a workaround way+ ) finally got one. ) can build a newschema, then create a set of iews referring to the e%isting schema, inoling theflashback query feature. nd ) can use a "global parameter" to control the flashbackscn*timestamp.

    Here is the code.

    SQL 

    1. -- ################################################################################ 

    2. -- # 

    3. -- # $Id: schema_snapshot.sql 

    4. -- # 

    5. -- # File: $RCSile: schema_snapshot.sql!" $ 

    . -- # esc%iption: c%eate a snapshot o% a schema 

    &. -- # 'sa(e: sqlpl)s -s *nolo( +schema_snapshot ,eistin(_schema_name ,snapshot_schema_name 

    /. -- # C%eated: 0&*02*2014 

  • 8/17/2019 Flashback Snapshot of Schema

    2/49

    . -- # )tho%: ei )an( 

    10. -- # 'se% %)n as: * as ssd6a 78S )se% sho)ld 6e o%acle o9ne% 

    11. -- # ;a%amete%s: 1: eistin( schema name 

    12. -- # ;a%amete%s: 2: ne9 schema name 

    13. -- # ;a%amete%s: 3: snapshot timestamp 

    14. -- # 

    15. -- # Cop%i(ht 7c 2014 ei )an( 

    1. -- # 

    1&. -- # isto% 

    1/. -- #

  • 8/17/2019 Flashback Snapshot of Schema

    3/49

    35. CRBB 8R RB;DCB ;CEB @2."a%_pG( IS 

    3.   "a% "a%cha%27255= 

    3&.   ;R8CB'RB set_"a%7"al "a%cha%2= 

    3/.   )nction (et_"a% %et)%n "a%cha%2= 

    3. BH "a%_pG( = 

    40. * 

    41.  

    42. CRBB 8R RB;DCB ;CEB 8J @2."a%_pG( IS 

    43.   ;R8CB'RB set_"a%7"al "a%cha%2 IS 

    44.   BIH 

    45.   "a% :> "al= 

    4.   end set_"a%= 

    4&.  

    4/.   )nction (et_"a% %et)%n "a%cha%2

    4.   IS 

    50.   BIH 

    51.   %et)%n "a%= 

    52.   BH (et_"a%= 

    53. BH "a%_pG(= 

    54. * 

    55. K?=

    5.  

    5&.   execute immediate sql_st%=

    5/.   for q in 7select ?(%ant select!lash6acG on ?LLo9ne%LL?.?LLta6le_nameLL? to?LL)ppe%7?@2?LL?=? st% from  d6a_ta6les  where o9ne%>)ppe%7?@1? loop

    5.   execute immediate q.st%=

    0.   end  loop=

  • 8/17/2019 Flashback Snapshot of Schema

    4/49

    1.   for q in 7select ?c%eate o% %eplace "ie9 ?LL)ppe%7?@2?LL?.M_?LLta6le_nameLL? as select N %om ?LLo9ne%LL?.?LLta6le_nameLL? as o timestamp to_timestamp7"a%_pG(.(et_"a%!??mmddhh24miss??=? from  d6a_ta6les  where o9ne%>)ppe%7?@1? loop

    2.   execute immediate q.st%=

    3.   end  loop=

    4.   for q in 7select ?c%eate o% %eplace snonm ?LL)ppe%7?@2?LL?.?LLta6le_nameLL? o% ?LL)ppe%7?@2?LL?.M_?LLta6le_nameLL?=? from  d6a_ta6les  where o9ne%>)ppe%7?@1? loop

    5.   execute immediate q.st%=

    .   end  loop=

    &.  

    /.   @2."a%_pG(.set_"a%7?@3?=

    .   end  i=

    &0. end =

    &1. *

    This will generate the code to create a "snapshot schema". -lients connecting thisschema will query all the data before the specified time. f course, if there are

     procedures*iews in the e%isting schema, they should be created in the new schemareferring to those synonyms.

    Consistent Gets may not tell the truth

    -onsistent gets is important statistics data indicating the performance of a /01. )t&s ametric data for us to tune /01. 2ormally, we may compare the performance of two/01 or same /01 with different e%ecution plan. Howeer, sometimes, -3 may nottell us the release performance of /01.

    1et&s reiew below 4 statistics data output first.

    SQL 

    1. SOD 1:

    2.   Statistics 

  • 8/17/2019 Flashback Snapshot of Schema

    5/49

    3. ---------------------------------------------------------- 

    4.   0 %ec)%si"e calls

    5.   0 d6 6locG (ets

    .   40 consistent (ets

    &.   0 phsical %eads

    /.   0 %edo size 

    .   12035/3 6tes sent "ia SODNHet to client

    10.   3// 6tes %ecei"ed "ia SODNHet from  client

    11.   30 SODNHet %o)ndt%ips to*from  client

    12.   0 so%ts 7memo%

    13.   0 so%ts 7disG

    14.   453 rows p%ocessed

    15.  

    1. SOD 2:

    1&. Statistics 

    1/. ---------------------------------------------------------- 

    1.   0 %ec)%si"e calls

    20.   0 d6 6locG (ets

    21.   1& consistent (ets

    22.   0 phsical %eads

    23.   0 %edo size 

    24.   2&325 6tes sent "ia SODNHet to client

    25.   3// 6tes %ecei"ed "ia SODNHet from  client

    2.   30 SODNHet %o)ndt%ips to*from  client

    2&.   1 so%ts 7memo%

    2/.   0 so%ts 7disG

    2.   453 rows p%ocessed

  • 8/17/2019 Flashback Snapshot of Schema

    6/49

    The consistent gets of the st /01 is almost 5 times of the 4nd one. /eems the 4ndmust hae better performance. )sn&t it+

    k, let&s go back to see how did these data got.

    SQL 

    1. ello.C8

  • 8/17/2019 Flashback Snapshot of Schema

    7/49

    24.  

    25. Bec)tion ;lan

    2. ---------------------------------------------------------- 

    2&. ;lan hash "al)e: 31&2013

    2/.  

    2. -------------------------------------------------------------------------- 

    30. L Id L 8pe%ation L  Name L Rows  L tes L Cost 7PC;'L Time  L

    31. -------------------------------------------------------------------------- 

    32. L 0 L SELECT SB

  • 8/17/2019 Flashback Snapshot of Schema

    8/49

    51. ello.C8?SJS?=

    52.  

    53. 453 rows selected.

    54.  

    55. Blapsed: 00:00:00.23

    5.  

    5&. Bec)tion ;lan

    5/. ---------------------------------------------------------- 

    5. ;lan hash "al)e: 132314/2&

    0.  

    1. ----------------------------------------------------------------------------- 

    2. L Id L 8pe%ation L  Name L Rows  L tes L Cost 7PC;'L Time  L

    3. ----------------------------------------------------------------------------- 

    4. L 0 L SELECT SB

  • 8/17/2019 Flashback Snapshot of Schema

    9/49

    &/. ---------------------------------------------------------- 

    &.   0 %ec)%si"e calls

    /0.   0 d6 6locG (ets

    /1.   1& consistent (ets

    /2.   0 phsical %eads

    /3.   0 %edo size 

    /4.   2&325 6tes sent "ia SODNHet to client

    /5.   3// 6tes %ecei"ed "ia SODNHet from  client

    /.   30 SODNHet %o)ndt%ips to*from  client

    /&.   1 so%ts 7memo%

    //.   0 so%ts 7disG

    /.   453 rows p%ocessed

    These 4 /01s are simple. )f we ignore the performance statistics data, we can easilydetermine their performance from their logical structure or from their e%ecution plan666 The performance of the st one must be better than the 4nd one, because there isone more full table scan in the e%ecution plan.

    Then why the 4nd one has less consistent gets+

    /et /01 Trace for them, and then look into the formatted trace file.

    SQL 

    1.   Rows 71st Rows 7a"( Rows 7 max Ro9 So)%ce 8pe%ation

    2. ---------- ---------- ---------- --------------------------------------------------- 

    3.   453 453 453 1& p%>0 p9>0 time>3/433 )s cost>52 size>11/5 ca%d>453

    4.   1 1 1 TABLE CCBSS !LL 2 7c%>3 p%>0 p9>0 time>&/)s cost>3 size>113 ca%d>1

    5.   453 453 453 'FFBR S8R 7c%>14 p%>0 p9>0 time>225/ )scost>4 size>110424 ca%d>453

    .   453 453 453 TABLE CCBSS !LL 1 7c%>14 p%>0 p9>0 time>11/15 )s cost>4 size>110424 ca%d>453

  • 8/17/2019 Flashback Snapshot of Schema

    10/49

    This is the plan statistics data of the 4nd /01. biously, there are 4 parts ofconsistent gets, FT/ on t and FT/ on t4.

    )n this plan, FT/ on t is 78. But why the st /01 got 877+ That is because of fetcharray size. 9efault array size of /01:;lus is

  • 8/17/2019 Flashback Snapshot of Schema

    11/49

    SQL 

    1. ello.C8

  • 8/17/2019 Flashback Snapshot of Schema

    12/49

    4.   54 54 54 TABLE CCBSS !LL 2 7c%>55 p%>0 p9>0 time>&2/ )s cost>3 size>102 ca%d>54

    5.   24402 24402 24402 'FFBR S8R 7c%>14 p%>0 p9>0 time>43354 )scost>2550 size>110424 ca%d>453

    .   453 453 453 TABLE CCBSS !LL 1 7c%>14 p%>0 p9>0 time

    >10&4 )s cost>4& size>110424 ca%d>453

    - of FT/ on t is unchanged, while - of FT/ on t4 is increased to

  • 8/17/2019 Flashback Snapshot of Schema

    13/49

    /. ---------------------------------------------------------- 

    . ;lan hash "al)e: &/&4&3//

    10.  

    11. ----------------------------------------------------------------------------- 

    12. L Id L 8pe%ation L  Name L Rows  L tes L Cost 7PC;'L Time  L

    13. ----------------------------------------------------------------------------- 

    14. L 0 L SELECT SB

  • 8/17/2019 Flashback Snapshot of Schema

    14/49

    lthough the e%ecution plan is not changed, the consistents gets is increasedsignificantly.

     

    'hat we should note from this case is,

      Fetch array size affects the consistent gets.

      -onsistent gets statistics data will only include the gets from shared buffer

     

    Test enironment? racle .4.#.5 on racle 1inu% < 78bit

    One single SQL helps you to analyze the

    performance of a SQL

    This is the script ) am using to analyze /01 performance. )t maDor contains one /01only. )t can show below information if aailable. nd you can shoose to show parts of

    them.

    •   : >onitored*-aptured Bind Iariables

    •   : /01 Te%t

    •   : C%ecution ;lan

    •   : ;eeJed Binds of the e%ecution plan

    •   : ;lan utline 9ata

    •   : ;lan ;redicate

    •   : ;lan 1ines 1oading

    •   : 'ait eents

  • 8/17/2019 Flashback Snapshot of Schema

    15/49

    •   : ;erformance /tatistics 9ata

    C%ample?

    SQL 

    1. ello.C8

  • 8/17/2019 Flashback Snapshot of Schema

    16/49

    23. exec :I?I&

    2. exec :I:>231

    2&.  

    2/. --SI: 1&0!511&5 

    2. "a% CCB;IS MRCR2732

    30. "a% BH231

    45.  

    4.  

    4&. ------------- SOD et -------------- 

    4/.  

    4. SELECT *NT leadin(7oe % l N*

  • 8/17/2019 Flashback Snapshot of Schema

    17/49

    50.   *N SH_RB;_8;_;R8F N*

    51.   mlelement7

    52.   top_p%oiles!

    53.   mla((7mlelement7o6U_id! o6Uect_id

    54.   R#$   7SELECT tasG_id! eec_name! eec_id! eec_sta%t! o6Uect_id! sql_id!

    55.   pa%sin(_schema! ph"! o6U_att%/

    5.   R#$   7SELECT *NT ca%dinalit7o 5 leadin(7e o N*

    5&.   e.tasG_id tasG_id!

    5/.   e.eec)tion_name eec_name!

    5.   e.eec)tion_id eec_id!

    0.   e.eec)tion_sta%t eec_sta%t!

    1.   o.id o6Uect_id!

    2.   o.att%1 sql_id!

    3.   o.att%3 pa%sin(_schema!

    4.   to_n)m6e%7n"l7o.att%5! ?0? ph"!

    5.   n"l7o.att%/!0 o6U_att%/!

    .   %o9_n)m6e%7 o"e%

    &.   7pa%tition  b" o.att%1

    /.   order  b"  6itand7o.att%&! 32 asc!

    .   e.eec)tion_sta%t desc

    &0.   %n

    &1.   R#$   7SELECT e.tasG_id! e.name eec)tion_name! e.id eec)tion_id!

    &2.   e.eec_sta%t eec)tion_sta%t! e.stat)s stat)s#

    &3.   R#$  7SELECT  tasG_id!

    &4.    min7eec)tion_name Geep 7dense_%anG first order  b" 

    &5.   eec)tion_sta%t 6ename!

  • 8/17/2019 Flashback Snapshot of Schema

    18/49

    &.    max7eec)tion_name Geep 7dense_%anG last order  b" 

    &&.   eec)tion_sta%t eename!

    &/.    min7eec)tion_sta%t 6esta%t!

    &.    max7eec)tion_sta%t eesta%t

    /0.   R#$   7SELECT tasG_id! name eec)tion_name!

    /1.   eec_sta%t eec)tion_sta%t

    /2.   R#$   9%i$_ad"_eec)tions

    /3.    %&ERE  tasG_id > :tid and 

    /4.   name in 7:6ename! :eename

    /5.   'R#!( B) tasG_id %!

    /.   9%i$_ad"_eec)tions e

    /&.  

    //.  

    /.    %&ERE e.tasG_id > %.tasG_id and 

    0.   e.eec_sta%t > 6esta%t and 

    1.   e.eec_sta%t ,> eesta%t and 

    2.   e.stat)s IH 73! 4 and 

    3.   76ename , eename 8R e.name > 6ename e *N e N*!

    4.   9%i$_ad"_o6Uects o

    5.    %&ERE  o.tasG_id > e.tasG_id H 

    .   o.eec_name > e.eec)tion_name H 

    &.   o.tpe > :sqltp

    /.    %&ERE %n > 1 oe *N oe N*!

    .   9%i$_ad"_indin(s !

    100.   9%i$_ad"_%ecommendations %!

    101.   9%i$_ad"_%ationale l

    102.    %&ERE  oe.tasG_id > .tasG_id H oe.eec_name > .eec_name H 

  • 8/17/2019 Flashback Snapshot of Schema

    19/49

    103.   oe.o6Uect_id > .o6U_id H .tasG_id > %.tasG_id H 

    104.   .eec_name > %.eec_name H .id > %.indin(_id H 

    105.   l.tasG_id > %.tasG_id H l.eec_name > %.eec_name H 

    10.   l.%ec_id > %.id H 

    10&.   %.tpe > :p%oiletp H l.tpe > :impltp H 

    10/.   l.att%1 > :acceptdis H 

    10.   H8 BVISS 7SELECT 1

    110.   R#$   d6a_sql_p%oiles p

    111.    %&ERE  p.tasG_id > %.tasG_id H 

    112.   p.tasG_eec_name > %.eec_name H 

    113.   p.tasG_o6U_id > oe.o6Uect_id H 

    114.   p.tasG_nd_id > %.indin(_id H 

    115.   p.tasG_%ec_id > %.id

    11.  

    11&.  

    11/. ------------- SOD ;lan 7;lan ash Mal)e:5/3&// -------------- 

    11.  

    120.   0 7 SELECT SBDD_R8S

    121.   1 70 S8R 7RBB

    122.   2 71 HBSB D88;S 7HI 7Cost>30 Ca%d>11 rows tes>0*12

    123.   3 72 HBSB D88;S 7Cost>2 Ca%d>11 rows tes>0*12

    124.   4 73 HBSB D88;S 7Cost>11 Ca%d>15 rows tes>0*3

    125.   5 74 HBSB D88;S 7Cost> Ca%d>0/ rows tes>0*54

    12.   # 75  *+E%  7Cost>/ Ca%d>2/ rows tes>0*31

    12&.   #& 7 IH8 7S8R ;'SB RHE 7Cost>/ Ca%d>4/ rows tes>0*123

    12/.   / 7& HBSB D88;S

  • 8/17/2019 Flashback Snapshot of Schema

    20/49

    12.   7/ HBSB D88;S 7Cost>& Ca%d>1& rows tes>0*123

    130.   10 7 HBSB D88;S 7Cost>5 Ca%d>33 rows tes>0*/4

    131.   11 710  *+E%  7Cost>3 Ca%d>1 rows tes>0*5&

    132.   12 711 S8R 7'R#!( B) 7Cost>3 Ca%d>1 rows tes>0*24

    133.   13 712 TABLE CCBSS 7B) +N,E- R8I # ?RI$_M_BVBC'I8HS? 7TABLE 7Cost>3 Ca%d>2 rows tes>0*24

    134.   N#14 713 +N,E- 7RHB SCH # ?RI$_M_BVBCS_;E? 7+N,E- 7!N+Q!E 7Cost>2 Ca%d>2 rows tes>0*

    135.   #15 710 TABLE CCBSS 7B) +N,E- R8I # ?RI$_M_BVBC'I8HS? 7TABLE 7Cost>2 Ca%d>33 rows tes>0*2&

    13.   N1 715 +N,E- 7RHB SCH # ?RI$_M_BVBCS_IV_03? 7+N,E- 7Cost>1 Ca%d>33 rows tes>0*

    13&.   N1& 7 +N,E- 7RHB SCH # ?RI$_M_8QBCS_IV_01? 7+N,E- 7!N+Q!E 7Cost>1 Ca%d>1& rows tes>0*

    13/.   #1/ 7/ TABLE CCBSS 7B) +N,E- R8I # ?RI$_M_8QBCS? 7TABLE 7Cost>2 Ca%d>134 rows tes>0*2&3

    13.   N1 75 +N,E- 7RHB SCH # ?RI$_M_FIHIHS_IV_02? 7+N,E- 7!N+Q!E 7Cost>1 Ca%d>0/ rows tes>0*23

    140.   #20 74 TABLE CCBSS 7B) +N,E- R8I # ?RI$_M_RBC815 rows tes>0*3

    141.   N21 720 +N,E- 7RHB SCH # ?RI$_M_RBCS_IV_02? 7+N,E- 7!N

    +Q!E 7Cost>1 Ca%d>345 rows tes>0*

    142.   #22 73 TABLE CCBSS 7B) +N,E- R8I # ?RI$_M_RI8HDB? 7TA BLE 7Cost>15 Ca%d>11 rows tes>0*3

    143.   N23 722 +N,E- 7RHB SCH # ?RI$_M_RI8HDB_;E? 7+N,E- 7!N+Q!E 7Cost>3 Ca%d>2&23304 rows tes>0*

    144.   24 72  *+E%  ;'SB ;RBICB # ?M_SO_1? 7 *+E%  7Cost>4 Ca%d>0 rows tes>0*

    145.   25 724 HBSB D88;S 7Cost>4 Ca%d>0 rows tes>0*240

    14.   2 725 HBSB D88;S 7Cost>4 Ca%d>0 rows tes>0*204

    14&.   N2& 72 S Q8IH 7Cost>4 Ca%d>0 rows tes>0*1/

    14/.   #2/ 72& TABLE CCBSS 7B) +N,E- R8I # ?SOD8Q$'V? 7TABLE 7Cost>2 Ca%d>0 rows tes>0*42

    14.   N2 72/ +N,E- 7RHB SCH # ?I_SOD8Q$'V_SE? 7+N,E-7Cost>1 Ca%d>0 rows tes>0*

  • 8/17/2019 Flashback Snapshot of Schema

    21/49

    150.   N#30 72& +N,E- 7SEI; SCH # ?SOD8Q$_;EBJ? 7+N,E- 7!N+Q!E 7Cost>1 Ca%d>0 rows tes>0*322

    151.   N31 72 +N,E- 7!N+Q!E SCH # ?I_SOD$BV_;EBJ? 7+N,E- 7!N+Q!E

    152.   N32 725 +N,E- 7!N+Q!E SCH # ?I_SOD$_;EBJ? 7+N,E- 7!N+Q!E

    153.  

    154. ------------- ;%edicate Ino%mation 7;lan ash Mal)e:5/3&// -------------- 

    155.  

    15.   Filte%: RH>1

    15&.   & Filte%: R8_H'.SIH'RB H S8.CB8RJ>.CB8RJ 

    1&0.  2/ Filte%: .8Q_J;B>1

    1&1.  2 ccess: .SE_I>R.SE_I H .SE_BVBC_HR.BVBC_H8QBC_I H .SE_FH_I>R.FIHIH_I H .SE_RBC_I>R.I 

  • 8/17/2019 Flashback Snapshot of Schema

    22/49

    1&2.  30 ccess: S8.8Q_J;B>1

    1&3.  30 Filte%: S8.8Q_J;B>1

    1&4.  31 ccess: S8.SIH'RB>S.SIH'RB 

    1&5.  32 ccess: S8.SIH'RB>SO.SIH'RB 

    1&.  

    1&&. ------------- ;lan Doadin( 7;lan ash Mal)e:5/3&// -------------- 

    1&/.  

    1&.  22: TABLE CCBSS B) +N,E- R8I #############################################7/.4&P

    1/0.  23: +N,E- RHB SCH #####710.53P

    1/1.  

    1/2. ------------- aits B"ents 7;lan ash Mal)e:5/3&// -------------- 

    1/3.  

    1/4.   #N C;' on SJS.RI$_M_RBCS_IV_027+N,E-#####7.5P

    1/5.  

    1/. ------------- Statistics ata -------------- 

    1/&.  

    1//. Doads: 1

    1/.   Load  Me%sions: 1

    10.   irst Load  Time: 2014-03-12*22:4:24

    11.   Last Load  Time: 2014-03-12*22:4:24

    12. 'se% 8penin(s: 0

    13. ;a%se Calls: 11

    14. Bec)tions: 11

    15. So%ts7"e%a(e: 2

    1. Fetches7"e%a(e: 1

    1&. isG Reads7"e%a(e: .545

  • 8/17/2019 Flashback Snapshot of Schema

    23/49

    1/. )e% ets7"e%a(e: 141/43.34

    1. Blapsed Time7"e%a(e: 10.50& seconds

    200. C;' Time7"e%a(e: 10.501 seconds

    201. R)n Time 

  • 8/17/2019 Flashback Snapshot of Schema

    24/49

      SELECT (!)*+_name,m- no_mere,/inv- 0O_MER1E,/2SEL32-!(stat4s5 s

      6 7ROM ,sele8t (!)*+_name,inv- no_mere,v-!(o.o9ner5 o.stat4s5o.o+:e8t_name5 o.8reate$5 t.ta+lesa8e_name &rom v_o+:e8ts_s;s o5 t_ta+les t

    9

  • 8/17/2019 Flashback Snapshot of Schema

    25/49

     

    Comparing the trace content. )e can /nd the optimizer performed simple /lter push

    analysis'

    7D Consi$erin simle &ilter 4s< ,re re9rite- in *4er; +lo8 M ,N-

    7D C4rrent 9

  • 8/17/2019 Flashback Snapshot of Schema

    26/49

    MODEL_COMPILE_SUBQUERY 

    &sage' MO!L"COMP#L!"S&6Q&!3%

    escription' &n5no)n* #t might ,e used for model (uery transformation*

    MODEL_DONTVERIFY_UNIQUENESS

    &sage' MO!L"O$+7!3#4%"&$#Q&!$!SS

    escription' &n5no)n* #t might ,e used for model (uery transformation*

    MODEL_DYNAMIC_SUBQUERY 

    &sage' MO!L"%$AM#C"S&6Q&!3%

    escription' &n5no)n* #t might ,e used for model (uery transformation*

    Partitioning Hints8"%$"P3&$!

    &sage' 8"%$"P3&$!

    escription' #nstructs the SQL e9ecutor to using the result of su, (uery to prune the

    partitions dynamically*

    HELLODBA.COM>alter session set tra8e&ile_i$enti&ier = '

  • 8/17/2019 Flashback Snapshot of Schema

    27/49

     

    HELLODBA.COM>e%e8 s*l_e%lain,'sele8t (!)4se_

  • 8/17/2019 Flashback Snapshot of Schema

    28/49

    HELLODBA.COM>e%e8 s*l_e%lain,'sele8t (!) 4se_mere,tr t- SBQERG_R0F01,trARTFTFO0-!(tr.! &rom t_o+:e8ts_rane tr5 t_ta+les t 9

  • 8/17/2019 Flashback Snapshot of Schema

    29/49

    escription' Pre0ents the optimizer to using su, (uery to prune the partitions dynamically*

    HELLODBA.COM>e%e8 s*l_e%lain,'sele8t (!)0O_SBQERG_R0F01,O ARTFTFO0-LEADF01,4-!(o.! &rom t_o+:e8ts_rane o5 t_ta+les t5 t_4sers 4 9?@6loc5B @+a,leBD

  • 8/17/2019 Flashback Snapshot of Schema

    30/49

    escription' #nstructs the optimizer to con0ert the O,Eect to a relational ta,le. similar to

    3!LA+#O$AL function*

    HELLODBA.COM>$es8 %mlta+le

     0ame 04ll T;e

     

     TABLE o& BLFC.MLTGE

     

    HELLODBA.COM>sele8t ! &rom %mlta+le#

     

    SGS_0C_RO?F07O3

    @ot

      @o4tline_$ata>

      @

      @F10ORE_OTFM_EMBEDDED_HF0TS(>

      @(

      ... ...

      @(o4tline_$ata>

    @(ot

     

    J ro9 sele8te$.

     

    HELLODBA.COM>sele8t (!) relational,%- !(! &rom %mlta+le %#

     

  • 8/17/2019 Flashback Snapshot of Schema

    31/49

    SGS_0C_OFD3 MLDATA

    ABC6CDAIKJ76IAAKJII@ot@o4tline_$ata>@@F10ORE_OTFM_EMBEDDED_HF0TS>@(F10ORE_OTFM_EMBED

    DED_HF0TS>@(@@OTFMFXER_7EATRES_E0ABLE>J...6@(OTFMFXER_7EATRES_E

    0ABLE>@(@@Y[CDATA[ALL_RO?S"">@(@@OTLF0E_LEA7>2SEL36BAJADC2

     

    MONITOR

    &sage' MO$#+O3

    escription' #nstruct Oracle monitor the running status of the statement. regardless of

    )hether it ful/lls the criteria >Parallel Query or 3unning for more than F secondsD or not*

    HELLODBA.COM>ssele8t (!) monitor !(8o4nt,!- &rom t_4sers 4#

     

    CO0T,!-

      6J

     

    HELLODBA.COM>sele8t s*l_te%t5 stat4s &rom v3s*l_monitor 9

  • 8/17/2019 Flashback Snapshot of Schema

    32/49

    'ZmonitorZ'#

     

    SQL_TET STATS

    sele8t (!) monitor !(8o4nt,!- &rom t_4sers 4 DO0E ,ALL RO?S-

    NO_MONITOR

    &sage' $O"MO$#+O3

    escription' Pre0ent Oracle monitor the running status of the statement. regardless of

    )hether it ful/lls the criteria >Parallel Query or 3unning for more than F secondsD or not*

    HELLODBA.COM>sele8t (!) no_monitor arallel,o - &4ll,o- !( (!i$enti&ier!(8o4nt,!- &rom t_o+:e8ts o#

     

    CO0T,!-

      JJ

     

    HELLODBA.COM>sele8t s*l_te%t5 stat4s &rom v3s*l_monitor 9CREATE OR RELACE TGE simle_t;e AS TABLE O7 UARCHAR,6-#

  • 8/17/2019 Flashback Snapshot of Schema

    33/49

      (

     

    T;e 8reate$.

     

    HELLODBA.COM>CREATE TABLE t_nt_ta+le ,a 0MBER5 + simle_t;e- 0ESTED TABLE +STORE AS t_nt_+#

     

    Ta+le 8reate$.

     

    HELLODBA.COM>F0SERT (!) !( F0TO t_nt_ta+le sele8t o+:e8t_i$5simle_t;e,o+:e8t_name- &rom t_o+:e8ts#

     

    JJ ro9s 8reate$.

     

    Elase$ JI.HH

     

    HELLODBA.COM>F0SERT (!) 0ESTED_TABLE_7AST_F0SERT !( F0TO t_nt_ta+le sele8to+:e8t_i$5 simle_t;e,o+:e8t_name- &rom t_o+:e8ts#

     

    JJ ro9s 8reate$.

     

    Elase$ H.HK

    NESTED_TABLE_GET_REFS

    &sage' $!S+!"+A6L!"G!+"3!4S

    escription' 1ith this hint. user can access to nested ta,le directly*

  • 8/17/2019 Flashback Snapshot of Schema

    34/49

    HELLODBA.COM>sele8t (!) !(8o4nt,!- &rom T_0T_B#

    sele8t (!) !(8o4nt,!- &rom T_0T_B

      !

    ERROR at line J

    ORAIJ 8annot re&eren8e neste$ ta+le 8ol4mn's storae ta+le

     

    HELLODBA.COM>sele8t (!) neste$_ta+le_et_re&s !(8o4nt,!- &rom T_0T_B#

     

    CO0T,!-

      JJ

    NESTED_TABLE_SET_SETID

    &sage' $!S+!"+A6L!"S!+"S!+#

    escription' 1ith this hint. user can access to nested ta,le directly*

    HELLODBA.COM>sele8t (!) 0ESTED_TABLE_SET_SETFD !(8o4nt,!- &rom T_0T_B#

     

    CO0T,!-

      JJ

    NO_MONITORING

    &sage' $O"MO$#+O3#$G

    escription' Pre0ent Oracle monitor the column usage in predication. conse(uently. the

    dictionary ta,le col"usageI )ill not ,e updated ,y the e9ecution of the statement*

    HELLODBA.COM>sele8t lie_re$s &rom s;s.SQLT3_DBA_COL_SA1E_U 9

  • 8/17/2019 Flashback Snapshot of Schema

    35/49

    an$ ta+le_name = 'T_TABLES' an$ 8ol4mn_name = 'TABLE_0AME'#

     

    LFVE_REDS

      JI

     

    HELLODBA.COM>sele8t (!r4n,-!(8o4nt,!- &rom t_ta+les 9e%e8 $+ms_stats.atsele8t lie_re$s &rom s;s.SQLT3_DBA_COL_SA1E_U 9sele8t (!) no_monitorin !((!r4n,I-!(8o4nt,!- &rom t_ta+les 9

  • 8/17/2019 Flashback Snapshot of Schema

    36/49

    I=I an$ ta+le_name lie 'TZ'#

     

    CO0T,!-

      6

     

    HELLODBA.COM>e%e8 $+ms_stats.atsele8t lie_re$s &rom s;s.SQLT3_DBA_COL_SA1E_U 9sele8t (! 0o_T0E,- !((!)0O_SQL_T0E!(8o4nt,!- &rom t_4sers#

     

    CO0T,!-

      6J

  • 8/17/2019 Flashback Snapshot of Schema

    37/49

     

    HELLODBA.COM>e%e8 e%e8_name = $+ms_s*lt4ne.e%e84te_t4nin_tas ,tas_name5

    'EEC_'s4+str,tas_name5 lentsele8t $+ms_s*lt4ne.reort_t4nin_tas ,tas_name- &rom $4al#

    ... ...

    ADDFTFO0AL F07ORMATFO0 SECTFO0

    \]^ SQL `bc

     

    RESTRICT_ALL_REF_CONS

    &sage' 3!S+3#C+"ALL"3!4"CO$S

    escription' 3estricts all cascaded operations caused ,y referencing constraints in the

    transactions*

    HELLODBA.COM>sele8t o9ner5 ta+le_name5 8onstraint_name5 r_o9ner5r_8onstraint_name5 $elete_r4le &rom $+a_8onstraints 9

  • 8/17/2019 Flashback Snapshot of Schema

    38/49

     

    HELLODBA.COM>$elete (!)RESTRFCT_ALL_RE7_CO0S!(&rom t_ 9sele8t 8o4nt,a- &rom t_8 98ommit#

    8ommit

    !

    ERROR at line J

    ORAKJ transa8tion rolle$ +a8

    ORAK interit; 8onstraint ,DEMO.T_C_7V- violate$ 8alter session set 2_.+;_

  • 8/17/2019 Flashback Snapshot of Schema

    39/49

     

    HELLODBA.COM>e%e8 s*l_e%lain,'sele8t (!)*+_name,M- SE_CO0CAT,/M-!(o9ner58o4nt,J- &rom t_o+:e8ts o ro4 +; o9ner'5 'T

    GFCAL OTLF0E'-#

    lan e%e8 s*l_e%lain,'sele8t (!)*+_name,M-

    0O_SE_HASH_A11RE1ATFO0,/M-!(o9ner5 8o4nt,J- &rom t_o+:e8ts o ro4 +; o9ner'5'TGFCAL OTLF0E'-#

    lan

  • 8/17/2019 Flashback Snapshot of Schema

    40/49

    F$ Oeration 0ame Ro9s B;tes Cost ,ZC-Time

    SELECT STATEME0T 6 J6I JK ,I-

    J SORT 1RO BG  6 J6I JK ,I-

    F0DE 7AST 7LL SCA0 T_OBPECTS_FDI JJ V JI ,-

    BYPASS_RECURSIVE_CHECK 

    &sage' 6%PASS"3!C&3S#7!"CH!CJ

    escription' &n5no)n* #t might instruct the parser not do recursi0e chec5ing* #t could ,e

    o,ser0ed in the internal statement generated ,y Materialized 7ie) updating*

    emo'

    HELLODBA.COM>alter session set s*l_tra8e=tr4e#

     

    Session altere$.

     

    HELLODBA.COM>e%e8 $+ms_mvie9.re&res 'MU_TABLES'-#

     

    L(SQL ro8e$4re s488ess&4ll; 8omlete$.

     

    1e got ,elo) statement from the tracing content*

  • 8/17/2019 Flashback Snapshot of Schema

    41/49

    F0SERT (!) BGASS_RECRSFUE_C ECV !( F0TO2DEMO2.2MU_TABLES2,2O?0ER252TABLE_0AME252TABLESACE_0AME252CREATED252LAST_DDL_TFME2- SELECT2T2.2O?0ER252T2.2TABLE_0AME252T2.2TABLESACE_0AME252O2.2CREATED252O2.2LAST_DDL_TFM

    E2 7ROM 2T_TABLES2 2T252T_OBPECTS2 2O2 ?HERE 2T2.2O?0ER2=2O2.2O?0ER2 A0D

    2T2.2TABLE_0AME2=2O2.2OBPECT_0AME2 A0D 2O2.2OBPECT_TGE2=2SGS_B_2 A0D2T2.2TABLESACE_0AME2 FS 0OT 0LL

     

    BYPASS_UJVC

    &sage' 6%PASS"&K7C

    escription' &n5no)n* #t might instruct parser not chec5 uni(ue constraint for the Eoin 0ie)*

    #t could ,e o,ser0ed in the internal statement generated ,y Materialized 7ie)

    updating*

    1e got ,elo) statement from the trace /le generated in pre0ious demo*

    4$ate (!) BGASS_PUC !(  , sele8t s.stat4s stat4s &rom sna3 s5sna_re&time3 r 9e%e8 s*l_e%lain,'SELECT (!) $omain_in$e%_&ilter,t t_ta+les_$i%6- !(! 7ROM t_ta+les t ?HERE CO0TAF0S,o9ner5 ''aaa''5J-> A0D stat4s = ''UALFD'''5'TGFCAL'-#

     

    F$ Oeration 0ame Ro9s B;tes Cost,ZC- Time

  • 8/17/2019 Flashback Snapshot of Schema

    42/49

    SELECT STATEME0T J J ,-

    J

    J TABLE ACCESS BG F0DE RO?FD T_TABLES J J ,-J

    !   DOMAF0 F0DE  T_TABLES_DF6

    ,- J

     

    re$i8ate Fn&ormation ,i$enti&ie$ +; oeration i$-

     

    a88ess,2CTSGS2.2CO0TAF0S2,2O?0ER25'aaa'5J->-

      &ilter,2STATS2='UALFD'-

    NO_DOMAIN_INDEX_FILTER

    &sage' $O"OMA#$"#$!8"4#L+!3>?@6loc5B @+a,leB ?> @#nde9BDD or

    $O"OMA#$"#$!8"4#L+!3>?@6loc5B @+a,leB ?> @#nde9ed ColumnsBDD

    escription' Pre0ents the optimizer the push /lter to Composite omain #nde9*

    HELLODBA.COM>e%e8 s*l_e%lain,'SELECT (!) no_$omain_in$e%_&ilter,t t_ta+les_$i%6-!( ! 7ROM t_ta+les t ?HERE CO0TAF0S,o9ner5 ''aaa''5J-> A0D stat4s = ''UALFD'''5'TGFCAL'-#

     

    F$ Oeration 0ame Ro9s B;tes Cost,ZC- Time

  • 8/17/2019 Flashback Snapshot of Schema

    43/49

    SELECT STATEME0T J J ,-J

    ! J  TABLE ACCESS BG F0DE RO?FD T_TABLES J J ,-J

    ! DOMAF0 F0DE  T_TABLES_DF6 ,- J

     

    re$i8ate Fn&ormation ,i$enti&ie$ +; oeration i$-

     

    J &ilter,2STATS2='UALFD'-

      a88ess,2CTSGS2.2CO0TAF0S2,2O?0ER25'aaa'5J->-

     

    DOMAIN_INDEX_SORT

    &sage' OMA#$"#$!8"SO3+

    escription' #nstructs the optimizer the push sorting columns to Composite omain #nde9*

    HELLODBA.COM>e%e8 s*l_e%lain,'SELECT (!) $omain_in$e%_sort !( ! 7ROM t_ta+les t?HERE CO0TAF0S,ta+lesa8e_name5 ''aaa''5J-> ORDER BG ta+le_name5 s8ore,J- $es8'5'TGFCAL'-#

    lan

  • 8/17/2019 Flashback Snapshot of Schema

    44/49

    ,ZC- Time

    SELECT STATEME0T J J ,-J

    J TABLE ACCESS BG F0DE RO?FD T_TABLES J J ,-J

    ! DOMAF0 F0DE T_TABLES_DF ,- J

     

    re$i8ate Fn&ormation ,i$enti&ie$ +; oeration i$-

     

    a88ess,2CTSGS2.2CO0TAF0S2,2TABLESACE_0AME25'aaa'5J->-

     

    NO_DOMAIN_INDEX_ SORT

    &sage' $O"OMA#$"#$!8" SO3+

    escription' Pre0ents the optimizer the push sorting columns to Composite omain #nde9*

    HELLODBA.COM>e%e8 s*l_e%lain,'SELECT (!) no_$omain_in$e%_sort !( ! 7ROM t_ta+lest ?HERE CO0TAF0S,ta+lesa8e_name5 ''aaa''5J-> ORDER BG ta+le_name5 s8ore,J-$es8'5 'TGFCAL'-#

     

    F$ Oeration 0ame Ro9s B;tes Cost

  • 8/17/2019 Flashback Snapshot of Schema

    45/49

    ,ZC- Time

    SELECT STATEME0T J J ,- J

    J SORT ORDER BG  J J ,- J

    TABLE ACCESS BG F0DE RO?FD T_TABLES J J ,- J

    ! 6 DOMAF0 F0DE T_TABLES_DF ,- J

     

    re$i8ate Fn&ormation ,i$enti&ie$ +; oeration i$-

     

    6 a88ess,2CTSGS2.2CO0TAF0S2,2TABLESACE_0AME25'aaa'5J->-

     

    DST_UPGRADE_INSERT_CONV

    &sage' S+"&PG3A!"#$S!3+"CO$7

    escription' 1ith this hint. Oracle )ill add an internal function

    >O3A"S+"CO$7!3+>#$+!3$AL"4&$C+#O$>DDD to modify the column de/ned as +#M!S+AMP

    1#+H +#M! O$! )hen using pac5age 6MS"S+ to upgrade the time zone of the data,ase*

    NO_DST_UPGRADE_INSERT_CONV

    &sage' $O"S+"&PG3A!"#$S!3+"CO$7

    escription' 1ith this hint. Oracle )ill not add an internal function

    >O3A"S+"CO$7!3+>#$+!3$AL"4&$C+#O$>DDD to modify the column de/ned as +#M!S+AMP

    1#+H +#M! O$! )hen using pac5age 6MS"S+ to upgrade the time zone of the data,ase*

  • 8/17/2019 Flashback Snapshot of Schema

    46/49

    STREAMS

    &sage' S+3!AMS

    escription' &n5no)n* #t might instructs the SQL e9ecution to transfer the data in stream*

    DEREF_NO_REWRITE

    &sage' !3!4"$O"3!13#+!>@6loc5BD

    escription' &n5no)n* #t might pre0ent the optimizer to re)rite the Materialized 7ie)

    )ith 6L !4!33! option*

    MV_MERGE

    &sage' M7"M!3G!

    escription' &n5no)n* #t might ,e used for C&6!*

    EXPR_CORR_CHECK 

    &sage' !8P3"CO33"CH!CJ 

    escription' &n5no)n* #t might instruct the parser to do referencing chec5ing )here

    analyzing !9pression 4ilter*

    INCLUDE_VERSION

    &sage' #$CL&!"7!3S#O$

    escription' &n5no)n* #t could ,e o,ser0ed from the internal statement generated ,y

    Ad0anced 3eplication* #t might ,e used to 5eep the compati,ility )hen replicating data

    among data,ases )ith di2erent 0ersions*

    VECTOR_READ

    &sage' 7!C+O3"3!A

    escription' &n5no)n* #t might ,e used for 7ector 4ilter in hash Eoin*

    VECTOR_READ_TRACE

    &sage' 7!C+O3"3!A"+3AC!

    escription' &n5no)n* #t might ,e used for 7ector 4ilter in hash Eoin*

  • 8/17/2019 Flashback Snapshot of Schema

    47/49

    USE_WEAK_NAME_RESL

    &sage' &S!"1!AJ"$AM!"3!SL

    escription' &n5no)n* #t might instructs the parser using the internal name instead the user-

    de/ned name to /nd 3esource Location* #t could ,e o,ser0ed from the internal statements

    generated statistics data gathering and !9pression 4ilter*

    sele8t (!) no_arallel,t- no_arallel_in$e%,t- $+ms_stats 84rsor_salter session set events 's*l_tra8e 9ait=tr4e5 +in$=tr4e5

    lan_stat=all_e%e84tions'#

     

    Session altere$.

     

    HELLODBA.COM>F0SERT (!) 0ESTED_TABLE_7AST_F0SERT !( F0TO t_nt_ta+le sele8to+:e8t_i$5 simle_t;e,o+:e8t_name- &rom t_o+:e8ts#

     

    ... ...

     

    1e got ,elo) statement from the trace /le*

    F0SERT (!) 0O_ARTFAL_COMMFT RE7_CASCADE_CRSOR !( F0TO 2DEMO2.2T_0T_B2,20ESTED_TABLE_FD252COLM0_UALE2- UALES,J5 -

  • 8/17/2019 Flashback Snapshot of Schema

    48/49

    REF_CASCADE_CURSOR

    &sage' 3!4"CASCA!"C&3SO3

    escription' &n5no)n* #t might ,e used to pre0ent the commit of internal recursi0e

    transaction* #t could ,e o,ser0ed from the internal statements generated ,y maintenance of

    the ta,le )ith nested o,Eect*

    3efer to the demo of $O"PA3+#AL"COMM#+

    NO_REF_CASCADE

    &sage' $O"3!4"CASCA!

    escription' &n5no)n* #t might pre0ent the internal recursi0e statement to use the cascade

    cursor*

    SQLLDR

    &sage' SQLL3

    escription' &n5no)n* #t might ,e used in the internal statements generated ,y SQLLoader*

    SYS_RID_ORDER

    &sage' S%S"3#"O3!3

    escription' &n5no)n* #t might ,e used in the internal statements generated ,y

    maintenance of Materialized 7ie)*

    OVERFLOW_NOMOVE

    &sage' O7!34LO1"$OMO7!

    escription' &n5no)n* #t might pre0ent Oracle to mo0e the data of other segment )hen

    o0erNo) occurs due to partition splitting*

    LOCAL_INDEXES

    &sage' LOCAL"#$!8!S

    escription' &n5no)n

    MERGE_CONST_ON

    &sage' M!3G!"CO$S+"O$

  • 8/17/2019 Flashback Snapshot of Schema

    49/49

    escription' &n5no)n

    QUEUE_CURR

    &sage' Q&!&!"C&33

    escription' &n5no)n* #t might ,e used for Ad0anced Queue*

    CACHE_CB

    &sage' CACH!"C6>?@6loc5B @+a,leBD

    escription' &n5no)n* #t might ,e used for Ad0anced Queue*

     +race the process of 6MS"AQ*!Q&!&&! >deli0ery"mode is P!3S#S+!$+D. )e got ,elo)

    statement*

    $elete (!) CAC E_CB,2QETABLET2- !( &rom 2DEMO2.2QETABLET2 9