Hi Tom,
You mentioned this in one of your responses.
<<So, a procedure that has been running for 10 hours and finished in your window would dump ALL of its cpu time into your window.>>
Could you please clarify if this logic of dumping the time in the snapshot at the end of the procedure call also applies to I/O related data and elapsed time of SQLs?
Also, I assume that the same goes with AWR reports as well. Isn't it?
Thanks,
Mahesh
Followup March 3, 2010 - 11am Central time zone:
things change over time...ops$tkyte%ORA9IR2> create or replace function get_stat_val( p_name in varchar2 ) return number 2 as 3 l_val number; 4 begin 5 select b.value 6 into l_val 7 from v$statname a, v$mystat b 8 where a.statistic# = b.statistic# 9 and a.name = p_name; 10 11 return l_val; 12 end; 13 / Function created. ops$tkyte%ORA9IR2> ops$tkyte%ORA9IR2> select * from v$version; BANNER ---------------------------------------------------------------- Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production PL/SQL Release 9.2.0.8.0 - Production CORE 9.2.0.8.0 Production TNS for Linux: Version 9.2.0.8.0 - Production NLSRTL Version 9.2.0.8.0 - Production ops$tkyte%ORA9IR2> exec dbms_output.put_line( 'cpu before = ' || get_stat_val( 'CPU used by this session' ) ); cpu before = 4 PL/SQL procedure successfully completed. ops$tkyte%ORA9IR2> begin 2 for x in (select rownum r, big_table.* from big_table.big_table where rownum <= 100000) 3 loop 4 if (mod(x.r,10000) = 0) 5 then 6 dbms_output.put_line 7 ( to_char(x.r,'999,999,999') || 8 ') consistent gets= ' || get_stat_val( 'consistent gets' ) || 9 ' physical reads= ' || get_stat_val( 'physical reads' ) || 10 ' cpu time= ' || get_stat_val( 'CPU used by this session' ) ); 11 12 end if; 13 end loop; 14 end; 15 / 10,000) consistent gets= 10161 physical reads= 151 cpu time= 5 20,000) consistent gets= 20161 physical reads= 293 cpu time= 5 30,000) consistent gets= 30161 physical reads= 435 cpu time= 5 40,000) consistent gets= 40161 physical reads= 577 cpu time= 5 50,000) consistent gets= 50162 physical reads= 719 cpu time= 5 60,000) consistent gets= 60162 physical reads= 875 cpu time= 5 70,000) consistent gets= 70162 physical reads= 1017 cpu time= 5 80,000) consistent gets= 80162 physical reads= 1159 cpu time= 5 90,000) consistent gets= 90162 physical reads= 1301 cpu time= 5 100,000) consistent gets= 100162 physical reads= 1443 cpu time= 5 PL/SQL procedure successfully completed. ops$tkyte%ORA9IR2> exec dbms_output.put_line( 'cpu after = ' || get_stat_val( 'CPU used by this session' ) ); cpu after = 258 PL/SQL procedure successfully completed.
that shows in 9i, logical and physical IO were added as they were used, CPU - added after the call.
However,
ops$tkyte%ORA10GR2> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for Linux: Version 10.2.0.4.0 - Production NLSRTL Version 10.2.0.4.0 - Production ops$tkyte%ORA10GR2> exec dbms_output.put_line( 'cpu before = ' || get_stat_val( 'CPU used by this session' ) ); cpu before = 69 PL/SQL procedure successfully completed. ops$tkyte%ORA10GR2> begin 2 for x in (select rownum r, big_table.* from big_table.big_table where rownum <= 100000) 3 loop 4 if (mod(x.r,10000) = 0) 5 then 6 dbms_output.put_line 7 ( to_char(x.r,'999,999,999') || 8 ') consistent gets= ' || get_stat_val( 'consistent gets' ) || 9 ' physical reads= ' || get_stat_val( 'physical reads' ) || 10 ' cpu time= ' || get_stat_val( 'CPU used by this session' ) ); 11 12 end if; 13 end loop; 14 end; 15 / 10,000) consistent gets= 2823 physical reads= 262 cpu time= 77 20,000) consistent gets= 3072 physical reads= 388 cpu time= 84 30,000) consistent gets= 3321 physical reads= 514 cpu time= 91 40,000) consistent gets= 3564 physical reads= 640 cpu time= 98 50,000) consistent gets= 3807 physical reads= 766 cpu time= 104 60,000) consistent gets= 4040 physical reads= 892 cpu time= 112 70,000) consistent gets= 4288 physical reads= 1144 cpu time= 119 80,000) consistent gets= 4535 physical reads= 1270 cpu time= 126 90,000) consistent gets= 4779 physical reads= 1396 cpu time= 133 100,000) consistent gets= 5019 physical reads= 1522 cpu time= 139 PL/SQL procedure successfully completed. ops$tkyte%ORA10GR2> exec dbms_output.put_line( 'cpu after = ' || get_stat_val( 'CPU used by this session' ) ); cpu after = 139 PL/SQL procedure successfully completed.