DB growth queries

select to_char(creation_time, 'MM-RRRR') "Month", sum(bytes)/1024/1024/1024 "Growth in GB"
 from sys.v_$datafile
 where to_char(creation_time,'RRRR')='2017'
 group by to_char(creation_time, 'MM-RRRR')
 order by  to_char(creation_time, 'MM-RRRR');



 select b.tsname tablespace_name , MAX(b.used_size_mb) cur_used_size_mb , round(AVG(inc_used_size_mb),2)avg_increas_mb 
 from ( SELECT a.days,a.tsname , used_size_mb , used_size_mb - LAG (used_size_mb,1) OVER ( PARTITION BY a.tsname ORDER BY a.tsname,a.days) inc_used_size_mb
 from ( SELECT TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY') days  ,ts.tsname ,MAX(round((tsu.tablespace_usedsize* dt.block_size )/(1024*1024),2)) used_size_mb
 from dba_hist_tbspc_space_usage  tsu , dba_hist_tablespace_stat  ts ,dba_hist_snapshot  sp, dba_tablespaces  dt   where tsu.tablespace_id= ts.ts#
 AND tsu.snap_id = sp.snap_id
 AND ts.tsname = dt.tablespace_name AND sp.begin_interval_time > sysdate-7
 GROUP BY TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY'), ts.tsname
 ORDER BY ts.tsname, days ) a ) b GROUP BY b.tsname ORDER BY b.tsname;


 SELECT o.OWNER , o.OBJECT_NAME , o.SUBOBJECT_NAME , o.OBJECT_TYPE ,    t.NAME "Tablespace Name", s.growth/(1024*1024) "Growth in MB",    (SELECT sum(bytes)/(1024*1024)    FROM dba_segments    WHERE segment_name=o.object_name) "Total Size(MB)"FROM DBA_OBJECTS o,    ( SELECT TS#,OBJ#,        SUM(SPACE_USED_DELTA) growth    FROM DBA_HIST_SEG_STAT    GROUP BY TS#,OBJ#    HAVING SUM(SPACE_USED_DELTA) > 0    ORDER BY 2 DESC ) s,    v$tablespace tWHERE s.OBJ# = o.OBJECT_IDAND s.TS#=t.TS#AND rownum < 51ORDER BY 6 DESC;

 SELECT o.OWNER , o.OBJECT_NAME , o.SUBOBJECT_NAME , o.OBJECT_TYPE ,
    t.NAME "Tablespace Name", s.growth/(1024*1024) "Growth in MB",
    (SELECT sum(bytes)/(1024*1024)
    FROM dba_segments
    WHERE segment_name=o.object_name) "Total Size(MB)"
FROM DBA_OBJECTS o,
    ( SELECT TS#,OBJ#,
        SUM(SPACE_USED_DELTA) growth
    FROM DBA_HIST_SEG_STAT
    GROUP BY TS#,OBJ#
    HAVING SUM(SPACE_USED_DELTA) > 0
    ORDER BY 2 DESC ) s,
    v$tablespace t
WHERE s.OBJ# = o.OBJECT_ID and o.owner='LAB'
AND s.TS#=t.TS#
AND rownum < 51
ORDER BY 6 DESC

Comments

Popular posts from this blog

Understanding Terraform

How to make CRS and ASM not to restart after server reboot

How to repair ASM disk header