-
Notifications
You must be signed in to change notification settings - Fork 63
/
log_switches.sql
52 lines (44 loc) · 1.2 KB
/
log_switches.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
REM Script Name : log_switches.sql
REM Author : Craig Richards
REM Created : 18 March 2013
REM Last Modified :
REM Version : 1.0
REM
REM Modifications :
REM
REM Description : Show information about recent log switches in the database, orginally got FROM http://www.dba-oracle.com/tips_oracle_v$_log_history.htm
COLUMN c1 format a10 HEADING "Month"
COLUMN c2 format a25 HEADING "Archive Date"
COLUMN c3 format 999 HEADING "Switches"
COMPUTE AVG of C on A
COMPUTE AVG of C on REPORT
BREAK ON A skip 1 ON REPORT SKIP 1
SELECT TO_CHAR(TRUNC(first_time), 'Month') c1,
TO_CHAR(TRUNC(first_time), 'Day : DD-Mon-YYYY') c2, COUNT(*) c3
FROM v$log_history
WHERE TRUNC(first_time) > last_day(sysdate-100) +1
GROUP BY TRUNC(first_time);
REM Daily COUNT and Size of Redo Log Space (Single Instance)
SELECT A.*, ROUND(A.COUNT#*B.AVG#/1024/1024) Daily_Avg_Mb
FROM
(
SELECT
TO_CHAR(First_Time,'YYYY-MM-DD') DAY,
COUNT(1) COUNT#,
MIN(RECID) Min#,
MAX(RECID) Max#
FROM
v$log_history
GROUP BY
TO_CHAR(First_Time,'YYYY-MM-DD')
ORDER BY 1 DESC
) A,
(
SELECT
AVG(BYTES) AVG#,
COUNT(1) COUNT#,
MAX(BYTES) Max_Bytes,
MIN(BYTES) Min_Bytes
FROM v$log
) B
;