A count of log switches per hour hides the five minutes that matter. This script cuts history into windows of any length you choose and lists only the windows above your threshold, so you can line a burst up with the job that ran at that minute.
Usage
SQL> @redo_bursts.sql 3 10
The first argument is the window length in minutes. The second is the number of switches a window must exceed to be listed.
-- redo_bursts.sql: X-minute windows with more than N redo log switches
-- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/)
-- https://hashjoin.com/kb/oracle/log-switch-bursts/
--
-- Usage: @redo_bursts.sql <minutes> <switches>
-- @redo_bursts.sql 3 10 any 3-minute window with more than 10 switches
--
-- Reads v$log_history: history goes back control_file_record_keep_time days.
-- On RAC, every thread's switches count toward a window.
set verify off
set lines 132
set pages 200
select interval, &&1 minutes, count(*) switches
from (select to_char(trunc(t.first_time)
+ floor(((t.first_time - trunc(t.first_time))*24*60)/&&1)*&&1/24/60,
'YYYY/MM/DD HH24:MI') as interval
from v$log_history t
-- where t.first_time between to_date('2026-01-01 00:00','YYYY-MM-DD HH24:MI')
-- and to_date('2026-01-01 23:59','YYYY-MM-DD HH24:MI')
)
group by interval
having count(*) > &&2
order by interval desc;
undefine 1
undefine 2curl -O https://hashjoin.com/kb/oracle/log-switch-bursts/redo_bursts.sql
Reading the output
Each row is the start of a window and the number of switches in it. A common rule of thumb is about one switch every 15 to 20 minutes under normal load. Windows with a switch every minute or two point at a bulk load or a purge job that should be generating less redo (direct path with NOLOGGING where recovery allows it) or at redo logs that are too small (check their size with groups.sql from redo log switches per hour).
Gotchas
- History only goes back as far as the control file keeps it (
control_file_record_keep_time, 7 days by default). - On RAC, every thread counts. Add
thread#to the inner select and thegroup byto split by instance. - Windows are aligned to midnight. With a 7-minute window, the windows start at 00:00, 00:07, 00:14 and so on, so a burst can be split between two of them. Run it with two different lengths if a number looks borderline.
What it reads
Related
Tired of fixing the same thing twice?
HASHJOIN turns the checks and fixes your on-call runs by hand into tooling that gives the same answer every time. Fixed scope, and you own all of the code.
New fixes and field notes by email, about once a month.