05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 9 ■ REDO AND UNDO 305<br />

ops$tkyte@ORA10G> create or replace trigger after_insert_update_delete<br />

2 after insert or update or delete on T<br />

3 for each row<br />

4 begin<br />

5 null;<br />

6 end;<br />

7 /<br />

Trigger created.<br />

ops$tkyte@ORA10G> truncate table t;<br />

Table truncated.<br />

ops$tkyte@ORA10G> exec do_work( 'after trigger' );<br />

insert redo size = 505972 rows = 200 2,529.9 bytes/row<br />

update redo size = 856636 rows = 200 4,283.2 bytes/row<br />

delete redo size = 474176 rows = 200 2,370.9 bytes/row<br />

PL/SQL procedure successfully completed.<br />

The preceding output was from a run where the size of Y was 2,000 bytes. After all of the<br />

runs were complete, we are able to query the LOG table <strong>and</strong> see the following:<br />

ops$tkyte@ORA10G> break on op skip 1<br />

ops$tkyte@ORA10G> set numformat 999,999<br />

ops$tkyte@ORA10G> select op, rowsize, no_trig,<br />

before_trig-no_trig, after_trig-no_trig<br />

2 from<br />

3 ( select op, rowsize,<br />

4 sum(decode( what, 'no trigger', redo_size/rowcnt,0 ) ) no_trig,<br />

5 sum(decode( what, 'before trigger', redo_size/rowcnt, 0 ) ) before_trig,<br />

6 sum(decode( what, 'after trigger', redo_size/rowcnt, 0 ) ) after_trig<br />

7 from log<br />

8 group by op, rowsize<br />

9 )<br />

10 order by op, rowsize<br />

11 /<br />

OP ROWSIZE NO_TRIG BEFORE_TRIG-NO_TRIG AFTER_TRIG-NO_TRIG<br />

---------- -------- -------- ------------------- ------------------------<br />

delete 30 291 0 0<br />

100 364 -1 -0<br />

500 785 -0 0<br />

1,000 1,307 -0 -0<br />

2,000 2,371 0 -0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!