Damir Vadas, Oracle As I Learned - How To ... Redo Logs Generation
Damir Vadas, Oracle As I Learned - How To ... Redo Logs Generation
All around Internet there are many articles which says how to narrow redo log generation in Oracle. However I still found out my self in position to ask what is the real cause of redo log
generation. In this post I'll try to answer all aspects of the cause redo log generation. This subject is more interesting for those who are running stand by databases which redo log transport on
remote location may caused many problems.
Damir Vadas
Who is generating redo logs now?
LinkedIn profile
One of the first question, which cover firefighter is: "Who is generating redo logs in this moment". Idea is to determine action on ad hoc basis. For that I use following script, which I call oDesk Cert. Contractor
top_redo.sql: View my complete profile
/* ----------------------------------------------------------------------------- ?
Filename: top_redo.sql
select b.inst_id,
lpad((b.SID || ',' || lpad(b.serial#,5)),11) sid_serial,
b.username,
machine,
b.osuser,
b.status,
a.redo_mb Followers
from (select n.inst_id, sid,
round(value/1024/1024) redo_mb
from gv$statname n, gv$sesstat s Followers (28) Next
where n.inst_id=s.inst_id
and n.name = 'redo size'
and s.statistic# = n.statistic#
order by value desc
) a, Follow by
gv$session b Email
where b.inst_id=a.inst_id
and a.sid = b.sid
and rownum <= 30 Email address Submit
;
If you want to concentrate on real oracle users (avoid core Oracle processes in result) place next condition in outer where clause:
November 2017 ( 2 )
When and how many redo logs generation occurred?
October 2016 ( 1 )
Beside current analyze in many times wider analyze/compare is even more interesting. So questions like:
When do we have most of redo log generation? September 2015 ( 1 )
Where was the peak of log generation? August 2015 ( 4 )
Did we have any "strange" redo log generation? July 2014 ( 1 )
need a little different approach-query v$log_history view. It holds historic data which retention period is initially controlled with MAXLOGHISTORY, defined while creating database (fixed not March 2014 ( 1 )
changeable without recreation of control file) and CONTROL_FILE_RECORD_KEEP_TIME which is changeable. In mine case it was set to 31 days (exact number of days for longest month): October 2013 ( 1 )
September 2013 ( 4 )
SQL> show parameter CONTROL_FILE_RECORD_KEEP_TIME ?
July 2013 ( 2 )
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
June 2013 ( 2 )
------------------------------ ----------- ---------------------------------------------
control_file_record_keep_time integer 31 February 2013 ( 1 )
January 2013 ( 2 )
Script to gather data through mentioned period looks like.
December 2012 ( 1 )
/* ----------------------------------------------------------------------------- ?
November 2012 ( 1 )
Filename: rl.sql
October 2012 ( 4 )
CR/TR# :
September 2012 ( 3 )
Purpose : redo logs distribution per hours on each day ... July 2012 ( 4 )
June 2012 ( 2 )
Date : 07.08.2007.
Author : Damir Vadas, [email protected] May 2012 ( 4 )
April 2012 ( 3 )
Remarks : run as privileged user
March 2012 ( 2 )
Changes (DD.MM.YYYY, Name, CR/TR#):
February 2012 ( 3 )
--------------------------------------------------------------------------- */
set pagesize 120; January 2012 ( 3 )
set linesize 200;
col day for a8; December 2011 ( 3 )
spool rl.txt November 2011 ( 1 )
PROMPT Archive log distribution per hours on each day ...
October 2011 ( 4 )
select September 2011 ( 3 )
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", August 2011 ( 1 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'01',1,0)),'999') "01", July 2011 ( 2 )
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", April 2011 ( 3 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'04',1,0)),'999') "04", March 2011 ( 4 )
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", February 2011 ( 4 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'07',1,0)),'999') "07", January 2011 ( 6 )
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", December 2010 ( 2 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'10',1,0)),'999') "10", November 2010 ( 4 )
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", September 2010 ( 4 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'13',1,0)),'999') "13", August 2010 ( 5 )
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", July 2010 ( 4 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'16',1,0)),'999') "16", June 2010 ( 7 )
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", May 2010 ( 5 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'19',1,0)),'999') "19", February 2010 ( 3 )
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", January 2010 ( 13 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'22',1,0)),'999') "22",
December 2009 ( 8 )
to_char(sum(decode(substr(to_char(first_time,'HH24'),1,2),'23',1,0)),'999') "23",
COUNT(*) TOT November 2009 ( 6 )
from v$log_history
October 2009 ( 6 )
group by to_char(first_time,'YY-MM-DD')
order by day
;
Redo logs generation is grouped by hours where last column (TOT) is sum of all redo logs in one day. According this it is more then obvious where redo log generation was highest, so our interest
may be focused on presented point in time. Charles Hooper's Oracle
Notes
Presentation – Working with
How much is that in Mb? Oracle Database in VB.Net
with ODP.Net and Visual
Total redo logs size (and according that, archived log size) cannot be computed from previous query because not all redo log switches occur when redo log was full. For that you might want to use API Toolkit; Enhancing
this very easy query: Visual Manufacturing 9.0.0
2 years ago
SQL> select sum(value)/1048576 redo_MB from sys.gv_$sysstat where name = 'redo size'; ?
Dan McGhan's Oracle
REDO_MB
Blog
----------
Tutorial: Creating a
1074623.75 Component Similar to Super
LOV Using Native
SQL> Components
3 years ago
If you want to calculate on instance grouping, then use this:
Coskan's Approach to
SQL> select inst_id, sum(value)/1048576 redo_MB from sys.gv_$sysstat where name = 'redo size' ?
2 group by inst_id; Oracle
oratop from MOS
6 years ago
INST_ID REDO_MB
---------- ----------
1 370325.298
2 4712.567
4 405129.283
3 294457.100
SQL>
Let us focus on first segment "USR_RACUNI_MV", segment with highest number of changed blocks (what mean directly highest redo log generation). Just for information, this is
MATERIALIZED VIEW.
Result is like:
For both of examples it was impossible to find out number of rows changed according operation that was performed. Let us see output of another example (NC_TRANSACTION_OK_T table)
where we can meet with DDL that generate redo logs!
If you are focused on pure number of changes, then you might to perform query where inst_id and sql_id are irrelevant (excluded from query). Here is a little modified previous example, for
"Z_PLACENO" segment (pure oracle table):
Result is like:
Here you can see directly number executions and number of involved rows.
SNAP_TIME SUM(DB_BLOCK_CHANGES_DELTA) ?
----------- ---------------------------
...
11-01-28 11 1224240
11-01-28 12 702880
11-01-28 13 1410112
11-01-28 14 806416
11-01-28 15 2008912
11-01-28 16 1103648
...
As you can see in accented row, the numbers are the same as at the begging of topic.
The End
Regardless which approach you use, redo logs generation has important effects in proper management of Oracle RMAN backups as well as stand by databases.
Cheers!
60 comments :
Reply
Replies
100% agree.
Great work,
Thanks,
zafar
Reply
Thx !
Reply
Reply
Damir Vadas November 14, 2011 at 7:56 PM
Glad to help you Bob!
Reply
Replies
Reply
S
Reply
Replies
querying v$log_history will give you result based on instance you are logged in.
querying gv$log_history will give you result based whole RAC (all instances). Look in this RAC example:
[code]
SQL> select count(*) from v$log_history;
COUNT(*)
----------
39944
1 row selected.
Elapsed: 00:00:02.46
SQL> select count(*) from gv$log_history;
COUNT(*)
----------
159776
1 row selected.
Elapsed: 00:00:00.56
SQL>
[/code]
Reply
Although I knew which was the Redo generator, the complete work you've done here helped me indeed.
Thanks again,
Mike
Reply
Is it safe to assume whichever session/process is causing the REDOLOG, this is the same one that is generating the FLASHBACK log ?
Thanks.
Reply
Replies
Always happy when breaking distance between tech and managers ...
:-)
Reply
Replies
Reply
Replies
Reply
Replies
Reply
can you provide me the script to capture the no of redos generated per hour and their size per hour in the last one month ..
Thanks ,
Sameer
Reply
Replies
Damir Vadas February 5, 2013 at 7:17 PM
Reply
Replies
Reply
This is a very useful document and i am following this document for a long time to get the information of redo generation, currently i am struggling with FND_LOB table and SYSLOB
segment, there are high redo generation on these tables by when i check the attachments they are hardly 2 to 3 MB attachment uploaded during high redo generation but it created 400 to
500 archivelog file that is very strange.
Can you please help me troubleshoot the issue, any queries related to this will help
Thank you
Regards
shahrukh
Reply
Does "redo size" equate or proportioonal to db_block_changes_delta for all database operations including NOLOGGING operations?
Reply
Replies
Damir Vadas June 26, 2013 at 2:02 PM
Do not know. Let me know if you find out.
Reply
Replies
Reply
If you are focused on pure number of changes, then you might to perform query where inst_id and sql_id are irrelevant (excluded from query). Here is a little modified previous example,
for "Z_PLACENO" segment (pure oracle table):
SELECT when, sql, SUM(sx) executions, sum (sd) rows_processed
...
Reply
Replies
Yap,
Change first line of query to:
SELECT when, sql, SUM(exec_delta) executions, sum (rows_proc_delta) rows_processed
Hi Damir,
Thanks a lot for this queries. The query SELECT when, sql, SUM(exec_delta) executions, sum (rows_proc_delta) rows_processed .....(full query) when i execute it is getting
executed but not giving any output. What might be the reason? The database is 11.2.0.4.
Regards,
Imran
Reply
Your blogs are now officially my favorite. Would be nice if your scripts can be downloaded in one zip file though. :-) [ wishful thinking ]
Anyway, can you please advise how to modify the rl.sql script so that it shows DAY as the header and HOUR as the column.
Example as below:
Reply
Replies
Reply
excellent work
Replies
Reply
Thanks
Zafar
Reply
Reply
Replies
Reply
Anonymous September 19, 2019 at 6:04 PM
This is the best redo/archivelog investigation manual!
Reply
Replies
Reply
Publish Preview
Zagreb u srcu!