Tip

Archive log switch history

Here is a script to track archive log switching by the day and by the hour. Since most of the work on our databases take place between the 1st and 7th of the month, the script is limited by that. It shows you the number of switches by the hour and by the day. It's very informative when deciding on log sizes and the number of logs.

--Shows archive log history
--ARCHIVE LOGS SWITCHES BROKEN DOWN BY THE HOUR SINCE THE FIRST OF THE MONTH
set pages 500
set lines 132
set pause off
column TIMESTAMP format a17

break on DAY
COMPUTE SUM OF SWITCHES ON DAY
break on day

SELECT 
TO_CHAR(TRUNC(H.first_time),'DD-MON-YYYY') "DAY"
,TO_CHAR(H.FIRST_TIME,'HH24')||':00' "HOUR"
,count(*) "SWITCHES"
,TO_CHAR(AVG(A.blocks*a.block_size),'999,999,999,999') "AVGBYTES"
FROM
V$LOGHIST H
,V$ARCHIVED_LOG A
WHERE
H.SEQUENCE#=A.SEQUENCE#
--AND H.FIRST_TIME > SYSDATE - 10
AND H.FIRST_TIME > LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-1))+1
GROUP BY 
TRUNC(H.first_time)
,TO_CHAR(H.FIRST_TIME,'HH24')
ORDER BY 
TRUNC(H.first_time) DESC
,TO_NUMBER(TO_CHAR(H.FIRST_TIME,'HH24'))
/

Reader Feedback

Jeff W. writes: This tip looks worthwhile. Unfortunately, it does not run on our version of Oracle (7.3.4).

For More Information

  • What do you think about this tip? E-mail the editor at

    Requires Free Membership to View


This was first published in July 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.