Showing posts with label offline redo log. Show all posts
Showing posts with label offline redo log. Show all posts

Thursday, September 1, 2011

Trend Oracle Archive Graph : How much archive created y’day or last week


Often you want to show nice graphs/pictures to please your Colleagues. Here is an Excel graph I created to record Archive growth.
The following query shows a count and size of the redo log files by day:
– 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
;
This v$log_history script comes from Ilya Petrenko
Output of the script : Delete columns Min(RECID) Min#,   Max(RECID) Max#
DAYLOG COUNTDAILY_AVG_MB
02/07/2010984480
01/07/20101265760
30/06/2010542469
29/06/2010281280
28/06/2010371691
27/06/201014640
26/06/201014640
25/06/201014640
24/06/201019869
23/06/201014640
Copy this table into Excel & click on Chart Wizard. Select X,Y co-ordinates and you will get a nice picture like this

Wednesday, August 31, 2011

Locate Log Switch Interval on Day/Hourly Basis


–List Timing for Log Switch on different clustered instances with thread details
SET LINESIZE 150
COLUMN TIMESTAMP FORMAT A30
COLUMN THREAD_ID FORMAT 999
COLUMN INSTANCE_ID FORMAT 999
SELECT  to_char(first_time,’DD-MON-YYYY HH24:MI’) TIMESTAMP,thread# THREAD_ID,inst_id INSTANCE_ID
FROM    GV$log_history
where INST_ID=&&INST_ID and trunc(first_time) =trunc(sysdate)
ORDER BY 1 desc;
– Will return a graph indicating log switches done on daily/hourly basis
SET LINESIZE 150
COLUMN DAY FORMAT A3
COLUMN Total FORMAT 99G990
COLUMN h00 FORMAT 999
COLUMN h01 FORMAT 999
COLUMN h02 FORMAT 999
COLUMN h03 FORMAT 999
COLUMN h04 FORMAT 999
COLUMN h05 FORMAT 999
COLUMN h06 FORMAT 999
COLUMN h07 FORMAT 999
COLUMN h08 FORMAT 999
COLUMN h09 FORMAT 999
COLUMN h10 FORMAT 999
COLUMN h11 FORMAT 999
COLUMN h12 FORMAT 999
COLUMN h13 FORMAT 999
COLUMN h14 FORMAT 999
COLUMN h15 FORMAT 999
COLUMN h16 FORMAT 999
COLUMN h17 FORMAT 999
COLUMN h18 FORMAT 999
COLUMN h19 FORMAT 999
COLUMN h20 FORMAT 999
COLUMN h21 FORMAT 999
COLUMN h22 FORMAT 999
COLUMN h23 FORMAT 999
COLUMN h24 FORMAT 999
BREAK ON REPORT
COMPUTE MAX OF “Total” ON REPORT
COMPUTE MAX OF “h00″ ON REPORT
COMPUTE MAX OF “h01″ ON REPORT
COMPUTE MAX OF “h02″ ON REPORT
COMPUTE MAX OF “h03″ ON REPORT
COMPUTE MAX OF “h04″ ON REPORT
COMPUTE MAX OF “h05″ ON REPORT
COMPUTE MAX OF “h06″ ON REPORT
COMPUTE MAX OF “h07″ ON REPORT
COMPUTE MAX OF “h08″ ON REPORT
COMPUTE MAX OF “h09″ ON REPORT
COMPUTE MAX OF “h10″ ON REPORT
COMPUTE MAX OF “h11″ ON REPORT
COMPUTE MAX OF “h12″ ON REPORT
COMPUTE MAX OF “h13″ ON REPORT
COMPUTE MAX OF “h14″ ON REPORT
COMPUTE MAX OF “h15″ ON REPORT
COMPUTE MAX OF “h16″ ON REPORT
COMPUTE MAX OF “h17″ ON REPORT
COMPUTE MAX OF “h18″ ON REPORT
COMPUTE MAX OF “h19″ ON REPORT
COMPUTE MAX OF “h20″ ON REPORT
COMPUTE MAX OF “h21″ ON REPORT
COMPUTE MAX OF “h22″ ON REPORT
COMPUTE MAX OF “h23″ ON REPORT
SELECT TRUNC(first_time) AS “Date”,
TO_CHAR(first_time, ‘Dy’) AS “Day”,
COUNT(1) AS “Total”,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’00′,1,0)) AS “h00″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’01′,1,0)) AS “h01″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’02′,1,0)) AS “h02″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’03′,1,0)) AS “h03″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’04′,1,0)) AS “h04″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’05′,1,0)) AS “h05″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’06′,1,0)) AS “h06″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’07′,1,0)) AS “h07″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’08′,1,0)) AS “h08″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’09′,1,0)) AS “h09″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’10′,1,0)) AS “h10″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’11′,1,0)) AS “h11″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’12′,1,0)) AS “h12″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’13′,1,0)) AS “h13″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’14′,1,0)) AS “h14″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’15′,1,0)) AS “h15″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’16′,1,0)) AS “h16″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’17′,1,0)) AS “h17″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’18′,1,0)) AS “h18″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’19′,1,0)) AS “h19″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’20′,1,0)) AS “h20″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’21′,1,0)) AS “h21″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’22′,1,0)) AS “h22″,
SUM(DECODE(TO_CHAR(first_time, ‘HH24′),’23′,1,0)) AS “h23″
FROM V$log_history
GROUP BY TRUNC(first_time), TO_CHAR(first_time, ‘Dy’)
ORDER BY 1;
CLEAR BREAKS;

Tuesday, July 12, 2011

Oracle Redo Log Generation


See how much redo logs you are generating per day. Good to use when you see your archivelog directories are filling up unusually.


This will not show you where the problem is though, will just give you the number of log switches and average MB generated per day so that you can compare day by day. If you do start seeing unusually high log switches, thus high volume of archivelog generation, maybe a good place to start is looking for transactions which do lots of UPDATE/DELETE operations in the STATSPACK.

I found this very nice SQL script on the Oracle website at this url :http://www.oracle.com/technology/oramag/code/tips2005/062705.html

Daily Count and Size of Redo Log Space (Single Instance)

SQL> 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;

Sample Output:

DAY COUNT# MIN# MAX# DAILY_AVG_MB
---------- ---------- ---------- ---------- ------------
2007-09-05 1 700 700 50
2007-09-04 1 699 699 50
2007-09-03 3 696 698 150
2007-09-02 2 694 695 100
2007-09-01 3 691 693 150
2007-08-31 4 687 690 200
2007-08-30 3 684 686 150
2007-08-29 2 682 683 100
2007-08-28 3 679 681 150
2007-08-27 3 676 678 150
2007-08-26 3 673 675 150



Hourly archivelog switches

There is another one which I find quite useful. I found it on the internet. I have also modified to show me a window of the last 7 days of the number of archivelog generation per hour (switches). I scripted it in unix so that shell sends me an email once a day with this log information. Very useful monitoring stuff!

SQL>SELECT to_date(first_time) 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
where to_date(first_time) > sysdate -8
GROUP by
to_char(first_time,'YYYY-MON-DD'), to_date(first_time)
order by to_date(first_time)
/


The output is like this:

DAY 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
--------- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
31-AUG-07 1 1 1 1 2 1 1 1 1 1 1 2 0 1 0 1 0 1 1 0 1 0 1 1
01-SEP-07 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 1 1 1 1 1 1
02-SEP-07 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 2 1 1 1 1
03-SEP-07 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 2
04-SEP-07 1 1 2 1 1 2 1 1 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 2
05-SEP-07 2 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2
06-SEP-07 2 1 2 2 2 2 1 2 2 2 2 2 1 2 2 1 0 2 0 0 0 0 1 0
07-SEP-07 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0