OracleRedo & archiving
Log switches per hour, last 7 days
A day-by-hour grid of log switches. Aim for roughly four an hour at peak; consistently more means the redo logs are too small.
Not yet verified. How scripts are tested
1CLEAR COLUMNS2SET LINESIZE 200 PAGESIZE 100 TRIMOUT ON TAB OFF NUMWIDTH 33COLUMN day FORMAT A104COLUMN total FORMAT 999995 6SELECT TO_CHAR(first_time, 'YYYY-MM-DD') AS day,7 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '00', 1, 0)) AS h00,8 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '01', 1, 0)) AS h01,9 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '02', 1, 0)) AS h02,10 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '03', 1, 0)) AS h03,11 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '04', 1, 0)) AS h04,12 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '05', 1, 0)) AS h05,13 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '06', 1, 0)) AS h06,14 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '07', 1, 0)) AS h07,15 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '08', 1, 0)) AS h08,16 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '09', 1, 0)) AS h09,17 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '10', 1, 0)) AS h10,18 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '11', 1, 0)) AS h11,19 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '12', 1, 0)) AS h12,20 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '13', 1, 0)) AS h13,21 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '14', 1, 0)) AS h14,22 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '15', 1, 0)) AS h15,23 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '16', 1, 0)) AS h16,24 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '17', 1, 0)) AS h17,25 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '18', 1, 0)) AS h18,26 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '19', 1, 0)) AS h19,27 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '20', 1, 0)) AS h20,28 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '21', 1, 0)) AS h21,29 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '22', 1, 0)) AS h22,30 SUM(DECODE(TO_CHAR(first_time, 'HH24'), '23', 1, 0)) AS h23,31 COUNT(*) AS total32FROM v$log_history33WHERE first_time > TRUNC(SYSDATE) - 734GROUP BY TO_CHAR(first_time, 'YYYY-MM-DD')35ORDER BY day;36 37SET NUMWIDTH 10Save it as ora-log-switch-map.sql and run it with SQL> @ora-log-switch-map.
Open in denrepoRelated tool: Redo log sizing
More Oracle scripts: Redo & archiving
- Online redo log groups and membersEvery redo log group with its thread, sequence, archived flag, status, member file and size. More than one CURRENT per thread, or members missing…
- Archived redo generated per dayCount and size of archived logs for the last 14 days, from the local destination only so standby copies aren't double-counted. Useful for sizing the…
- Redo generated per hourActual redo volume per hour for the last 7 days, from archived log sizes on the local destination, so early log switches and Data Guard copies don't…
- Sessions generating the most redoConnected sessions ranked by redo generated since logon. Finds the job behind a sudden flood of archive logs.