Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

select round((select sum(bytes)/(1024*1024*1024) from dba_data_files)) Total ,

round(((select sum(bytes)/(1024*1024*1024) from dba_data_files)


- (select sum(bytes)/(1024*1024*1024) from dba_free_space))) Used ,
round((select sum(bytes)/(1024*1024*1024) from dba_free_space)) Free
from dual;

Database growth from AWR


------------------------

Declare
v_BaselineSize number(20);
v_CurrentSize number(20);
v_TotalGrowth number(20);
v_Space number(20);
cursor usageHist is
select a.snap_id,
SNAP_TIME,
sum(TOTAL_SPACE_ALLOCATED_DELTA) over ( order by a.SNAP_ID) ProgSum
from
(select SNAP_ID,
sum(SPACE_ALLOCATED_DELTA) TOTAL_SPACE_ALLOCATED_DELTA
from DBA_HIST_SEG_STAT
group by SNAP_ID
having sum(SPACE_ALLOCATED_TOTAL) <> 0
order by 1 ) a,
(select distinct SNAP_ID,
to_char(END_INTERVAL_TIME,'DD-Mon-YYYY HH24:Mi') SNAP_TIME
from DBA_HIST_SNAPSHOT) b
where a.snap_id=b.snap_id;
Begin
select sum(SPACE_ALLOCATED_DELTA) into v_TotalGrowth from DBA_HIST_SEG_STAT;
select sum(bytes) into v_CurrentSize from dba_segments;
v_BaselineSize := v_CurrentSize - v_TotalGrowth ;

dbms_output.put_line('SNAP_TIME Database Size(MB)');

for row in usageHist loop


v_Space := (v_BaselineSize + row.ProgSum)/(1024*1024);
dbms_output.put_line(row.SNAP_TIME || ' ' || to_char(v_Space) );
end loop;
end;

Database growth in GB
---------------------
SET PAGESIZE 5000
SELECT
TO_char(creation_time, 'RRRR Month') "Month"
, SUM(bytes)/1024/1024 "Growth in Meg"
FROM
sys.v_$datafile
WHERE creation_time > SYSDATE-365
GROUP BY TO_CHAR(creation_time, 'RRRR Month');

select to_char(first_time,'DD-MON-YY') Day , count(*) "Num of Logs"from


v$log_history
where to_char(first_time,'DD-MON-YY') > sysdate -16 group by
to_char(first_time,'DD-MON-YY')
order by to_char(first_time,'DD-MON-YY');
Num requests per days
-------------------------
select to_char(request_date,'DD-MON-YYYY') Day, count(*) "Num of Requests"
from apps.fnd_concurrent_requests
where to_char(request_date,'DD-MON-YYYY') > sysdate -30
group by to_char(request_date,'DD-MON-YYYY')
order by Day;

Top n segments by size


----------------------
col segment_name format a40
set lines 200
set pages 200
select owner,
segment_name,
segment_type,
Size_in_GB
from (select owner,
segment_name,
segment_type,
round((bytes/1024/1024/1024),2) Size_in_GB
from dba_segments
where owner not in ('SYS','SYSTEM')
order by 4 desc)
where rownum <= 20;

Segments with highest growth (Top n):


-------------------------------------
col OWNER format a10
col "Tablespace Name" format a18
col OBJECT_NAME format a40
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 s.TS#=t.TS#
AND rownum < 51
ORDER BY 7 DESC;

column owner format a16


column object_name format a36
column start_day format a11
column block_increase format 9999999999
select * from
(select obj.owner, obj.object_name,
sum(a.db_block_changes_delta) Block_Changes
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 end_interval_time between to_timestamp('20-DEC-2016','DD-MON-RRRR')
and to_timestamp('20-JAN-2017','DD-MON-RRRR')
group by obj.owner, obj.object_name
order by sum(a.db_block_changes_delta) DESC)
where rownum < 21;

Long running concurrent programs


--------------------------------

col USER_CONCURRENT_PROGRAM_NAME format a60


select * from (select USER_CONCURRENT_PROGRAM_NAME, count(*) as "Cnt in 15 days",
avg((nvl(actual_completion_date,sysdate)-actual_start_date)*1440 ) as avg_time,
max((nvl(actual_completion_date,sysdate)-actual_start_date)*1440 ) max_time,
min((nvl(actual_completion_date,sysdate)-actual_start_date)*1440 ) min_time
from apps.FND_CONC_REQ_SUMMARY_V
where phase_code='C' and status_code='C' and
USER_CONCURRENT_PROGRAM_NAME not in ('Abort','Deactivate Concurrent
Manager','Activate Concurrent Manager','Abort Concurrent Manager', 'Notification
Mailer','Shutdown Concurrent Manager','Request Set Stage','Report Set','Shutdown')
group by concurrent_program_id,USER_CONCURRENT_PROGRAM_NAME
order by avg_time desc ) where rownum < 21;

High frequency programs list


----------------------------
select * from (select USER_CONCURRENT_PROGRAM_NAME, count(*)/15 as Times,
avg((nvl(actual_completion_date,sysdate)-actual_start_date)*1440 ) as avg_time,
max((nvl(actual_completion_date,sysdate)-actual_start_date)*1440 ) max_time,
min((nvl(actual_completion_date,sysdate)-actual_start_date)*1440 ) min_time
from apps.FND_CONC_REQ_SUMMARY_V
where
phase_code='C' and status_code='C' and
USER_CONCURRENT_PROGRAM_NAME not in ('Abort Concurrent Manager', 'Notification
Mailer','Shutdown Concurrent Manager','Request Set Stage','Report Set')
group by concurrent_program_id,USER_CONCURRENT_PROGRAM_NAME
order by times desc ) where rownum < 21;

select * from (select sql_text,module,disk_reads "Physical reads"


,buffer_gets "LOGICAL READS", executions
,round(buffer_gets/decode(nvl(executions,0),0,1,executions),0)
"LOGICAL_READS/EXECUTIONS", round(cpu_time/(1000*1000*60*executions))
"CPUTIME/EXECUTION in Mins",
round(elapsed_time/(1000*1000*60*executions)) "ELAPSEDTIME/EXECUTION in
Mins",hash_value
from v$sqlarea
where
executions > 15 and
sql_text not like '%dba_%'
and round(cpu_time/(1000*1000*60*executions)) > 0
order by buffer_gets/decode(nvl(executions,0),0,1,executions) desc)
where rownum < 40;

List of queries to be executed for checking queries having bind variables


-------------------------------------------------------------------------

drop table gepsback.t1;


create table gepsback.t1 as select sql_text,module from v$sqlarea;

alter table gepsback.t1 add sql_text_wo_constants varchar2(4000);

create or replace function


gepsback.remove_constants( p_query in varchar2 ) return varchar2
as
l_query long;
l_char varchar2(100);
l_in_quotes boolean default FALSE;
begin
for i in 1 .. length( p_query )
loop
l_char := substr(p_query,i,1);
if ( l_char = '''' and l_in_quotes )
then
l_in_quotes := FALSE;
elsif ( l_char = '''' and NOT l_in_quotes )
then
l_in_quotes := TRUE;
l_query := l_query || '''#';
end if;
if ( NOT l_in_quotes ) then
l_query := l_query || l_char;
end if;
end loop;
l_query := translate( l_query, '0123456789', '@@@@@@@@@@' );
for i in 0 .. 8 loop
l_query := replace( l_query, lpad('@',10-i,'@'), '@' );
l_query := replace( l_query, lpad(' ',10-i,' '), ' ' );
end loop;
return upper(l_query);
end;
/

update gepsback.t1 set sql_text_wo_constants = gepsback.remove_constants(sql_text);

commit;

select sql_text_wo_constants, module, count(*)


from gepsback.t1
group by sql_text_wo_constants, module
having count(sql_text_wo_constants) > 200
order by count(sql_text_wo_constants) desc;

Sysadmin programs run information


---------------------------------

col USER_CONCURRENT_PROGRAM_NAME format a40


select USER_CONCURRENT_PROGRAM_NAME, max(actual_completion_date) last_run,
count(*) as "Times in Last 7 days"
from apps.FND_CONC_REQ_SUMMARY_V where
CONCURRENT_PROGRAM_ID in ( 38089, 32592 , 38121 ,32263 , 44967 ,39947 )
and phase_code='C' and status_code in ('C','G')
and actual_completion_date between sysdate-7 and sysdate
group by USER_CONCURRENT_PROGRAM_NAME,concurrent_program_id;

Any programs having trace enabled


---------------------------------

select concurrent_program_name, substr(user_concurrent_program_name,1,50)


USER_CONCURRENT_PROGRAM_NAME
from apps.fnd_Concurrent_programs_vl
where enable_trace = 'Y';

Reorg_recommendations
---------------------

select * from (select segment_owner,


segment_name,
segment_type,
round(reclaimable_space/1024/1024) reclaimable_Mb,
round(allocated_space/1024/1024) allocated_Mb,
round(used_space/1024/1024) current_size_mb,
round((reclaimable_space/1024/1024)/(allocated_space/1024/1024),2)*100
percent_fragmented
--RECOMMENDATIONS
from table (dbms_space.asa_recommendations())
order by reclaimable_space/1024/1024 desc)
where rownum < 20;

select owner,table_name,round((blocks*8),2)||'kb' "Fragmented size",


round((num_rows*avg_row_len/1024),2)||'kb' "Actual size", round((blocks*8),2)-
round((num_rows*avg_row_len/1024),2)||'kb',
((round((blocks*8),2)-round((num_rows*avg_row_len/1024),2))/
round((blocks*8),2))*100 -10 "reclaimable space % " from dba_tables where
table_name ='&table_Name' AND OWNER LIKE '&schema_name'

You might also like