Subscribe to Posts by Email

Subscriber Count

    701

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Script: Object or Table Growth from AWR

Hello All,

Sometimes we were been asked to provide the object or a table growth, Here is some nice script, which is useful to find the table growth per day for a given table;

select   obj.owner, obj.object_name,
           to_char(sn.BEGIN_INTERVAL_TIME,'RRRR-MON-DD') start_day,
           sum(a.db_block_changes_delta) block_increase
  from     dba_hist_seg_stat a,
           dba_hist_snapshot sn,
           dba_objects obj
  where    sn.snap_id = a.snap_id
  and      obj.object_id = a.obj#
  and      obj.owner not in ('SYS','SYSTEM')
  and        obj.object_name='TEST_HIST'
  and      end_interval_time between to_timestamp('01-JAN-2012','DD-MON-RRRR')
           and to_timestamp('29-NOV-2012','DD-MON-RRRR')
  group by obj.owner, obj.object_name,
           to_char(sn.BEGIN_INTERVAL_TIME,'RRRR-MON-DD')
  order by obj.owner, obj.object_name
  /


OWNER            OBJECT_NAME        START_DAY   BLOCK_INCREASE
---------------- -------------  -----------     --------------
TEST             TEST_HIST      2012-NOV-22          18704
TEST             TEST_HIST      2012-NOV-23           9968
TEST             TEST_HIST      2012-NOV-26          10688
TEST             TEST_HIST      2012-NOV-27          10064
TEST             TEST_HIST      2012-NOV-28          10336
SQL> SQL>

The output shows the number of blocks that increased per day, you can calculate blocks & db_block_size and get the exact size if required.

Update: Another method as updated latest by Laurent in his blog post at http://laurentschneider.com/wordpress/2012/12/how-big-was-my-table-yesterday.html

SELECT savtime,owner,object_name,rowcnt,blkcnt
FROM sys.WRI$_OPTSTAT_TAB_HISTORY w,
  dba_objects o
WHERE 
   o.owner='SCOTT'
   AND o.object_name='EMP'
   and o.object_id = W.OBJ#
ORDER BY o.owner, o.object_name, w.savtime;

 
SAVTIME           OWNER    OBJECT_NAME     ROWCNT     BLKCNT
----------------- -------- ----------- ---------- ----------
2012-11-06 06:49  SCOTT    EMP           13215425     120077
2012-11-13 07:28  SCOTT    EMP           12678535     120077
2012-11-20 03:15  SCOTT    EMP           12860640     120077
2012-11-27 03:19  SCOTT    EMP           13045850     120077
2012-12-04 05:41  SCOTT    EMP           13326460     120077

You can find other useful growth trend scripts here in this post:- http://db.geeksinsight.com/2012/10/15/scripts-databasetabletablespace-growth-report-using-awr/

-Hope this helps
Thanks
Geek DBA

1 comment to Script: Object or Table Growth from AWR