Oracle – Estimate tablespace growth over time using AWR

A decent enough DBA should be able to tell you this information off of the top of their head, but sometimes it’s useful to see on average how fast a tablespace has been growing.

If you’re licensed to use the AWR views, you can query DBA_HIST_TABLESPACE and DBA_HIST_TBSPC_SPACE_USAGE to trend tablespace growth over time. I like to find the average tablespace size, then view how it changes over time. The below query can show you that. It assumes that you have an 8kb value for DB_BLOCK_SIZE, adjust as necessary if not.

with tablespaces as (
  select ts.tsname, trunc(to_date(su.rtime, 'mm/dd/yyyy hh24:mi:ss')) as "DAY", avg((su.tablespace_usedsize*8192)/1024/1024/1024) as used_gb
  from dba_hist_tablespace ts
  join dba_hist_tbspc_space_usage su on su.tablespace_id = ts.ts#
  where ts.tsname = 'DATA1' 
  group by  ts.tsname, trunc(to_date(su.rtime, 'mm/dd/yyyy hh24:mi:ss'))
  order by 2 desc
) select tsname, day, to_char(used_gb, '999G999G999D999') used_gb, to_char(used_gb - lag(used_gb) over (order by used_gb), '999G999G999D999') diff
  from tablespaces
  order by 2 desc;

TSNAME DAY          USED_GB          DIFF
------ ------------ ---------------- ---------
DATA1  2024-12-09   1,719.020             .685
DATA1  2024-12-08   1,718.335             .643
DATA1  2024-12-07   1,717.693             .903
DATA1  2024-12-06   1,716.790            1.852
DATA1  2024-12-05   1,714.938            2.229
DATA1  2024-12-04   1,712.709            2.231
DATA1  2024-12-03   1,710.478            3.150
DATA1  2024-12-02   1,707.328            2.966
DATA1  2024-12-01   1,704.361            1.686
DATA1  2024-11-30   1,702.676             .886
DATA1  2024-11-29   1,701.790             .799
DATA1  2024-11-28   1,700.991            1.787
DATA1  2024-11-27   1,699.204            2.756
DATA1  2024-11-26   1,696.447            1.538
DATA1  2024-11-25   1,694.909            1.552
DATA1  2024-11-24   1,693.358            1.012

Hope this helps,
Dustin

Leave a Reply

Your email address will not be published. Required fields are marked *