Tuesday, April 21, 2015

Oracle 11.2.0.4.0 AWR "Tablespace IO Stats" Column Names Shifted

Oracle 11.2.0.4.0 added two new columns in Section "Tablespace IO Stats" and "File IO Stats":

 1-bk Rds/s
 Av 1-bk Rd(ms)


but in "Tablespace IO Stats", both Column Names do not match the content in the table.

Running the appended TestCase, we got the AWR report for "Tablespace IO Stats":


Tablespace Reads Av Rds/s Av Rd(ms) Av Blks/Rd 1-bk Rds/s Av 1-bk Rd(ms) Writes Writes avg/s Buffer Waits Av Buf Wt(ms)
TEST_TBS 25 6 0 7.6 87 1.54 0 22 0 0


and "File IO Stats":

Tablespace Filename Reads Av Rds/s Av Rd(ms) Av Blks/Rd 1-bk Rds/s Av 1-bk Rd(ms) Writes Writes avg/s Buffer Waits Av Buf Wt(ms)
TEST_TBS test_tbs.dbf 25 6 0 7.6 2 0 87 22 0 0


In "Tablespace IO Stats", "1-bk Rds/s" and "Av 1-bk Rd(ms)" have to be switched with Column "Writes" so that Names are in sync with Content.

Tablespace Reads Av Rds/s Av Rd(ms) Av Blks/Rd Writes 1-bk Rds/s Av 1-bk Rd(ms) Writes avg/s Buffer Waits Av Buf Wt(ms)
TEST_TBS 25 6 0 7.6 87 1.54 0 22 0 0


Another difference noticed is that both "Tablespace IO Stats" and "File IO Stats" report Read statistics:
     Av Rd(ms)
  Av Blks/Rd

but there are no symmetrical figures on Write like:
   *Av Wr(ms)
 *Av Blks/Wr


With following query, we can fulfil these statistics:

select filename, file#, snap_id, end_interval_time
      ,round(phyrds_d)                             "Reads"
      ,round(phyrds_d/interval_seconds)            "Av Reads/s"      
      ,round(readtim_d*10/nullif(phyrds_d, 0))     "Av Rd(ms)"       
      ,round(phyblkrd_d/nullif(phyrds_d, 0))       "Av Blks/Rd"  
      ,round(singleblkrds_d/interval_seconds)      "1-bk Rds/s"  
      ,round(singleblkrdtim_d*10/nullif(singleblkrds_d, 0))     "Av 1-bk Rd(ms)"
      ,round(phywrts_d)                            "Writes"  
      ,round(phywrts_d/interval_seconds)           "Av Writes/s"  
      ,round(writetim_d*10/nullif(phywrts_d, 0))   "*Av Wr(ms)"      -- * Not in AWR
      ,round(phyblkwrt_d/nullif(phywrts_d, 0))     "*Av Blks/Wr"     -- * Not in AWR
      ,round(wait_count_d)                         "Buffer Waits"  
      ,round(time_d*10/nullif(wait_count_d, 0))    "Av Buf Wt(ms)"   -- in CentiSeconds
from (
  select 
     phyrds - lag(phyrds) over(partition by file# order by snap_id) phyrds_d
    ,phywrts - lag(phywrts) over(partition by file# order by snap_id) phywrts_d
    ,singleblkrds - lag(singleblkrds) over(partition by file# order by snap_id) singleblkrds_d
    ,readtim - lag(readtim) over(partition by file# order by snap_id) readtim_d
    ,writetim - lag(writetim) over(partition by file# order by snap_id) writetim_d
    ,singleblkrdtim - lag(singleblkrdtim) over(partition by file# order by snap_id) singleblkrdtim_d
    ,phyblkrd - lag(phyblkrd) over(partition by file# order by snap_id) phyblkrd_d
    ,phyblkwrt - lag(phyblkwrt) over(partition by file# order by snap_id) phyblkwrt_d
    ,wait_count - lag(wait_count) over(partition by file# order by snap_id) wait_count_d   
    ,time - lag(time) over(partition by file# order by snap_id) time_d
    ,end_interval_time   
    ,interval_seconds
    ,t.*
from dba_hist_filestatxs t
   ,(select snap_id s_snap_id, end_interval_time 
           ,((sysdate + (end_interval_time - begin_interval_time)) - sysdate)*86400 interval_seconds 
       from dba_hist_snapshot)
where t.snap_id = s_snap_id
  and tsname = 'TEST_TBS'
  and snap_id >= (select max(snap_id) from dba_hist_snapshot) - 6
--  and end_interval_time > timestamp'2015-04-22 06:00:00'
);


TestCode


Run code block:

 drop tablespace test_tbs including contents;
 
 create tablespace test_tbs datafile 'test_tbs.dbf' size 100m reuse online;
 
 drop table testt;
 
 create table testt(x number, y varchar2(1000)) tablespace test_tbs;
 
 exec sys.dbms_workload_repository.create_snapshot('ALL'); 
 
 insert into testt select level x, rpad('abc', 1000, 'x') y from dual connect by level <= 1000;
 
 commit;
 
 alter system flush buffer_cache; 
 
 select count(*) from testt;
 
 exec dbms_lock.sleep(3);
 
 exec sys.dbms_workload_repository.create_snapshot('ALL'); 
 
 select bytes, blocks from dba_segments where segment_name = 'TESTT';
And get AWR report by:

select * from table(SYS.DBMS_WORKLOAD_REPOSITORY.awr_report_html(
  (select dbid from v$database), 1, 
  (select max(snap_id) from dba_hist_snapshot) - 1, 
  (select max(snap_id) from dba_hist_snapshot)));
There could exist other misleading information in AWR report. Recently we were puzzled by a high Session UGA and PGA memory reported in AWR, where UGA is much larger than PGA in a dedicated server:
  session pga memory max    308,253,725,520    302,308,652,008
  session uga memory max  5,614,577,384,552  5,666,238,828,552
At the end, we found one MOS Note:
    High Session UGA & PGA Memory Reported in AWR (Doc ID 1483177.1)
which said:
    These statistics will be removed from AWR report in future versions, could be 12.1 
    so you should not depend on these fake numbers for investigations of performance issues.