Anda di halaman 1dari 5

-----------------------------------------------------------------------------------

----------
This script will tell you about how many redo logs being generated by your database
per hour

select to_char(first_time,'MM-DD') day,


to_char(sum(decode(to_char(first_time,'hh24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'hh24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'hh24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'hh24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'hh24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'hh24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'hh24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'hh24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'hh24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'hh24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'hh24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'hh24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'hh24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'hh24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'hh24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'hh24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'hh24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'hh24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'hh24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'hh24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'hh24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'hh24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'hh24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'hh24'),'23',1,0)),'99') "23"
from v$log_history group by to_char(first_time,'MM-DD')
/
-----------------------------------------------------------------
---------------------------------------------------------------------------------
How to monitor the amount of redo generated per hour
At customer sites very often I can see the transaction load via the amount of redo
which was generated.

For best overview I like to query the amount of redo generated per hour:

SELECT Start_Date,
Start_Time,
Num_Logs,
Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),
2) AS Mbytes,
Vdb.NAME AS Dbname
FROM (SELECT To_Char(Vlh.First_Time,
'YYYY-MM-DD') AS Start_Date,
To_Char(Vlh.First_Time,
'HH24') || ':00' AS Start_Time,
COUNT(Vlh.Thread#) Num_Logs
FROM V$log_History Vlh
GROUP BY To_Char(Vlh.First_Time,
'YYYY-MM-DD'),
To_Char(Vlh.First_Time,
'HH24') || ':00') Log_Hist,
V$log Vl,
V$database Vdb
WHERE Vl.Group# = 1
ORDER BY Log_Hist.Start_Date,
Log_Hist.Start_Time;
Sample output:

START_DATE START_TIME NUM_LOGS MBYTES DBNAME


---------- ---------- ---------------------- ---------------------- ---------
2006-01-24 11:00 1 100 MYDB
2006-01-24 14:00 2 200 MYDB
2006-01-24 16:00 1 100 MYDB
2006-01-24 18:00 1 100 MYDB
2006-01-24 20:00 5 500 MYDB
2006-01-24 21:00 14 1400 MYDB
2006-01-24 22:00 11 1100 MYDB
2006-01-25 00:00 1 100 MYDB
...
-----------------------------------------------------------------------------------
---

How to monitor the amount of redo generated per hour


At customer sites very often I can see the transaction load via the amount of redo
which was generated.

For best overview I like to query the amount of redo generated per hour:

SELECT Start_Date,
Start_Time,
Num_Logs,
Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),
2) AS Mbytes,
Vdb.NAME AS Dbname
FROM (SELECT To_Char(Vlh.First_Time,
'YYYY-MM-DD') AS Start_Date,
To_Char(Vlh.First_Time,
'HH24') || ':00' AS Start_Time,
COUNT(Vlh.Thread#) Num_Logs
FROM V$log_History Vlh
GROUP BY To_Char(Vlh.First_Time,
'YYYY-MM-DD'),
To_Char(Vlh.First_Time,
'HH24') || ':00') Log_Hist,
V$log Vl,
V$database Vdb
WHERE Vl.Group# = 1
ORDER BY Log_Hist.Start_Date,
Log_Hist.Start_Time;
-----------------------------------------------------------------------------------
-------

Script to find archivelog generation per hour


Posted by Pavan DBA on February 7, 2012

5 Votes
set pagesize 120;
set linesize 200;
col day for a8;
spool archivelog.lst
PROMPT Archive log distribution per hours on each day …

select
to_char(first_time,’YY-MM-DD’) day,
to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’00’,1,0)),’999′) “00”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’01’,1,0)),’999′) “01”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’02’,1,0)),’999′) “02”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’03’,1,0)),’999′) “03”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’04’,1,0)),’999′) “04”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’05’,1,0)),’999′) “05”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’06’,1,0)),’999′) “06”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’07’,1,0)),’999′) “07”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’08’,1,0)),’999′) “08”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’09’,1,0)),’999′) “09”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’10’,1,0)),’999′) “10”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’11’,1,0)),’999′) “11”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’12’,1,0)),’999′) “12”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’13’,1,0)),’999′) “13”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’14’,1,0)),’999′) “14”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’15’,1,0)),’999′) “15”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’16’,1,0)),’999′) “16”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’17’,1,0)),’999′) “17”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’18’,1,0)),’999′) “18”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’19’,1,0)),’999′) “19”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’20’,1,0)),’999′) “20”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’21’,1,0)),’999′) “21”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’22’,1,0)),’999′) “22”,

to_char(sum(decode(substr(to_char(first_time,’HH24′),1,2),’23’,1,0)),’999′) “23”,

COUNT(*) TOT
from v$log_history
group by to_char(first_time,’YY-MM-DD’)
order by day ;
-----------------------------------------------------------------------------------
---

Track Redo Generation per hours and days


Here is the scripts for Tracking Redo Generation per Hours and by Days .

Track redo generation by day

SQL>select trunc(completion_time) rundate ,count(*) logswitch


,round((sum(blocks*block_size)/1024/1024)) “REDO PER DAY (MB)”
from v$archived_log group by trunc(completion_time) order by 1;

Sample Output :
RUNDATE LOGSWITCH REDO PER DAY (MB)
------------- ------------------ ----------------------
18-APR-11 2 1
19-APR-11 5 230
20-APR-11 36 1659
21-APR-11 14 175
22-APR-11 5 147

Track the Amount of Redo Generated per Hour :

SQL> SELECT Start_Date, Start_Time, Num_Logs,


Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),2) AS Mbytes, Vdb.NAME AS Dbname
FROM (SELECT To_Char(Vlh.First_Time, 'YYYY-MM-DD') AS Start_Date,
To_Char(Vlh.First_Time, 'HH24') || ':00' AS Start_Time, COUNT(Vlh.Thread#) Num_Logs
FROM V$log_History Vlh
GROUP BY To_Char(Vlh.First_Time, 'YYYY-MM-DD'),
To_Char(Vlh.First_Time, 'HH24') || ':00') Log_Hist,
V$log Vl , V$database Vdb
WHERE Vl.Group# = 1
ORDER BY Log_Hist.Start_Date, Log_Hist.Start_Time;

Sample Output :
START_DATE START NUM_LOGS MBYTES DBNAME
------------------------- ---------- --------- ---------
2011-04-18 16:00 1 50 NOIDA
2011-04-18 17:00 2 100 NOIDA
2011-04-19 00:00 1 50 NOIDA
2011-04-19 09:00 1 50 NOIDA
2011-04-19 14:00 1 50 NOIDA
2011-04-19 20:00 1 50 NOIDA
2011-04-19 23:00 1 50 NOIDA
2011-04-20 06:00 1 50 NOIDA
2011-04-20 10:00 5 250 NOIDA
2011-04-20 11:00 8 400 NOIDA
2011-04-20 12:00 21 1050 NOIDA
2011-04-20 14:00 1 50 NOIDA
2011-04-21 09:00 1 50 NOIDA
2011-04-21 13:00 3 150 NOIDA
2011-04-21 15:00 1 50 NOIDA
2011-04-21 17:00 8 40 NOIDA
2011-04-21 22:00 1 50 NOIDA
2011-04-22 00:00 1 50 NOIDA
2011-04-22 05:00 1 50 NOIDA
2011-04-22 14:00 2 100 NOIDA

-------------------------------------------------------------------------------

Anda mungkin juga menyukai