Find Sessions Generating Lots of Redo or Archive Logs

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

Whenever there is sudden burst of archive log generation, Keep this Handy, to find

Sessions Generating Lots of Redo or Archive logs.

In case of Emergency, you can estimate database survival for no of days based on
existing free space for archive log destination.

1) Archive Logs Generated Per Day

set lines 180

set pages 500

set feedback off

select trunc(first_time)" Date"


,round((sum(blocks)*block_size)/1024/1024)"Total Size(Mb)",

count(*) "# of Archive Logs Generated"

from v$archived_log

where trunc(first_time) >=trunc(sysdate -30)

group by trunc(first_time),block_size

order by trunc(first_time);

2) Archive Log Generated Per Hour for the last 30 Days.

set lines 180

set pages 500

set feedback off

SELECT trunc(first_time) "Day",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'999') " 00",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'999') "01",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'999') "02",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'999') "03",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'999') "04",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'999') "05",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'999') "06",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'999') "07",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'999') "08",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'999') "09",
TO_CHAR(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'999') "10",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'999') "11",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'999') "12",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'999') "13",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'999') "14",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'999') "15",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'999') "16",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'999') "17",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'999') "18",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'999') "19",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'999') "20",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'999') "21",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'999') "22",

TO_CHAR(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'999') "23"

FROM V$LOG_HISTORY

where trunc(first_time)>=trunc(sysdate -30 )

GROUP BY trunc(first_time)

order by trunc(first_time);

SQL: How to Find Sessions Generating Lots of Redo or Archive logs [Metalink ID
167492.1]

3) Query V$SESS_IO. This view contains the column BLOCK_CHANGES which indicates

how much blocks have been changed by the session. High values indicate a

session generating lots of redo.

Run the query multiple times and examine the delta between each occurrence

of BLOCK_CHANGES. Large deltas indicate high redo generation by the session.

SELECT s.sid, s.serial#, s.username, s.program,

i.block_changes

FROM v$session s, v$sess_io i

WHERE s.sid = i.sid


ORDER BY 5 desc, 1, 2, 3, 4;

4) Query V$TRANSACTION. This view contains information about the amount of

undo blocks and undo records accessed by the transaction (as found in the

USED_UBLK and USED_UREC columns).

The query you can use is:

SELECT s.sid, s.serial#, s.username, s.program,

t.used_ublk, t.used_urec

FROM v$session s, v$transaction t

WHERE s.taddr = t.addr

ORDER BY 5 desc, 6 desc, 1, 2, 3, 4;

You use the fourth query when you need to check for programs generating lots of

redo when these programs activate more than one transaction. The latter query

can be used to find out which particular transactions are generating redo.

5) REM The resources could be redo generation

select sid, value,name

from v$sesstat s, v$statname n

where n.statistic# = s.statistic#

and n.name = 'redo size' order by 2

6) REM The resources could be undo generation

select sid, value,NAME

from v$sesstat s, v$statname n

where n.statistic# = s.statistic#

and n.name like '%undo%' order by 2

You might also like