set linesize 120
col os_user format a10
col username format a15
col pid format 9999999999
PROMPT SESSIONS SORTED BY PHYSICAL READS
PROMPT
select
OSUSER os_user,username,
PROCESS pid,
ses.SID sid,
SERIAL#,
PHYSICAL_READS,
BLOCK_CHANGES
from v$session ses,
v$sess_io sio
where ses.SID = sio.SID
and username is not null
and status='ACTIVE'
order by PHYSICAL_READS;
|
Archive for the ‘Performance Tuning’ Category
Script – Sessions with high physical reads
Posted by Gavin Soorma on July 9, 2009
Posted in Performance Tuning, Scripts | Tagged: i/o, physical reads, top sessions, v$session, v$sess_io | Leave a Comment »
Script – Latch Contention (top 5 latches)
Posted by Gavin Soorma on July 6, 2009
This script will display the top 5 latches with the most sleeps.
Script can be changed to even sort the display on misses instead.
set linesize 120 col name format a30 select * from (select name, gets,misses, sleeps from v$latch order by sleeps desc) where rownum < 6;
Posted in Performance Tuning, Scripts | Tagged: latch, misses, sleeps, v$latch | Leave a Comment »
Script – Top SQL (Physical Reads)
Posted by Gavin Soorma on July 6, 2009
This script will list the top 5 SQL statements sorted by the most number of physical reads
set serverout on size 1000000
set feedback off
declare
top5 number;
text1 varchar2(4000);
x number;
len1 number;
Cursor c1 is
select disk_reads,substr(sql_text,1,4000)
from v$sqlarea
order by disk_reads desc;
begin
dbms_output.put_line('Reads'||' '||' Text');
dbms_output.put_line ('-----'||' '||'----------------------------------------------------');
dbms_output.put_line(' ');
open c1;
for i in 1 .. 5 loop
fetch c1 into top5, text1;
dbms_output.put_line(rpad(to_char(top5),9)|| ' '||substr(text1,1,66));
len1 :=length(text1);
x := 66;
while len1 > x-1 loop
dbms_output.put_line('" '||substr(text1,x,64));
x := x+64;
end loop;
end loop;
end;
/
Posted in Performance Tuning, Scripts | Tagged: disk reads, physical reads, top sql | Leave a Comment »
Script – Top SQL (Buffer Gets)
Posted by Gavin Soorma on July 6, 2009
This script will list the top 5 SQL statements sorted by the most number of buffer gets or logical reads
set serverout on size 1000000
declare
top5 number;
text1 varchar2(4000);
x number;
len1 number;
Cursor c1 is
select buffer_gets,substr(sql_text,1,4000)
from v$sqlarea
order by buffer_gets desc;
begin
dbms_output.put_line('Reads'||' '||' Text');
dbms_output.put_line ('-----'||' '||'---------------------------------------------------');
dbms_output.put_line(' ');
open c1;
for i in 1 .. 5 loop
fetch c1 into top5, text1;
dbms_output.put_line(rpad(to_char(top5),9)|| ' '||substr(text1,1,66));
len1 :=length(text1);
x := 66;
while len1 > x-1 loop
dbms_output.put_line('" '||substr(text1,x,64));
x := x+64;
end loop;
end loop;
end;
/
Posted in Performance Tuning, Scripts | Tagged: buffer gets, logical reads, top sql | Leave a Comment »
Script – Segments with highest I/O activity
Posted by Gavin Soorma on July 6, 2009
This script will list the top 10 segments in the database that have the most number of
physical reads against them.
Script can also be changed to query on 'physical writes' instead.
set pagesize 200
setlinesize 120
col segment_name format a20
col owner format a10
select segment_name,object_type,total_physical_reads
from ( select owner||'.'||object_name as segment_name,object_type,
value as total_physical_reads
from v$segment_statistics
where statistic_name in ('physical reads')
order by total_physical_reads desc)
where rownum <=10;
Posted in Administration, Performance Tuning, Scripts | Tagged: physical reads, physical writes, top segments, v$segment_statistics | Leave a Comment »
Script – What Wait Events Are Sessions Waiting On
Posted by Gavin Soorma on July 2, 2009
set linesize 120 col username format a10 col event format a30 select sid, serial#,username, event, seconds_in_wait, wait_time from v$session where state = 'WAITING' and wait_class != 'Idle' order by event ;
Posted in Performance Tuning, Scripts | Tagged: wait, wait event, wait_class | Leave a Comment »
Script – Sessions Waiting On A Particular Wait Event
Posted by Gavin Soorma on July 2, 2009
SELECT count(*), event
FROM v$session_wait
WHERE wait_time = 0
AND event NOT IN ('smon timer','pipe get','wakeup time manager',
'pmon timer','rdbms ipc message', 'SQL*Net message from client')
GROUP BY event
ORDER BY 1 DESC;
Posted in Performance Tuning, Scripts | Tagged: v$session_wait, wait event, wait interface | Leave a Comment »
Script – Datafiles with highest I/O activity
Posted by Gavin Soorma on July 1, 2009
col name format a40 set linesize 140 select * from ( select name,phyrds, phywrts,readtim,writetim from v$filestat a, v$datafile b where a.file#=b.file# order by readtim desc) where rownum <6;
Posted in Performance Tuning, Scripts | Tagged: datafile I/O, phyrds, phywrts, read, writes | Leave a Comment »
