Professional Documents
Culture Documents
ScriptCheckCurrentUndoConfigurationandAdviseRecommendedSetup(DocID
1579035.1)
InthisDocument
Goal
Solution
RDBMSversion10gandabove:
SampleOutput
RDBMSversion9iandbelow
SampleOutput
References
APPLIESTO:
OracleDatabaseEnterpriseEditionVersion8.1.7.0andlater
Informationinthisdocumentappliestoanyplatform.
***Checkedforrelevanceon05Apr2016***
GOAL
Thisdocumentisintendedtocheckthecurrentundoconfigurationandprovidesrecommendationbasedontheprevious
workload.AUTION
Thissamplecodeisprovidedfordiagnosisandtroubleshootingpurposesonly,andisNOTsupportedbyOracleSupport.
Ithasbeentestedinternally,however,wedonotguaranteethatitwillworkforyou.Ensurethatyourunitinyourtest
environmentbeforeusing.
Therearedifferentscriptsfordatabaseversionspost10gandpriorto10g.Ensuretoexecutethecorrectonetogetthe
properrecommendation.EnsuretoexecutethescriptasSYSuser.
SOLUTION
Fordatabaseversion10gandabove,usethefollowingscript.EnsuretoexecutethesameasSYSDBA.
RDBMSversion10gandabove:
SETSERVEROUTPUTON
SETLINES600
ALTERSESSIONSETNLS_DATE_FORMAT='DD/MM/YYYYHH24:MI:SS'
DECLARE
v_analyse_start_timeDATE:=SYSDATE7
v_analyse_end_timeDATE:=SYSDATE
v_cur_dtDATE
v_undo_info_retBOOLEAN
v_cur_undo_mbNUMBER
v_undo_tbs_nameVARCHAR2(100)
v_undo_tbs_sizeNUMBER
v_undo_autoextBOOLEAN
v_undo_retentionNUMBER(5)
v_undo_guaranteeBOOLEAN
v_instance_numberNUMBER
v_undo_advisor_adviceVARCHAR2(100)
v_undo_health_retNUMBER
v_problemVARCHAR2(1000)
v_recommendationVARCHAR2(1000)
v_rationaleVARCHAR2(1000)
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=omarzjxvc_341&id=1579035.1 1/4
21/6/2016 Document1579035.1
v_retentionNUMBER
v_utbsizeNUMBER
v_best_retentionNUMBER
v_longest_queryNUMBER
v_required_retentionNUMBER
BEGIN
selectsysdateintov_cur_dtfromdual
DBMS_OUTPUT.PUT_LINE(CHR(9))
DBMS_OUTPUT.PUT_LINE('UndoAnalysisstartedat:'||v_cur_dt||'')
DBMS_OUTPUT.PUT_LINE('')
v_undo_info_ret:=DBMS_UNDO_ADV.UNDO_INFO(v_undo_tbs_name,v_undo_tbs_size,v_undo_autoext,
v_undo_retention,v_undo_guarantee)
selectsum(bytes)/1024/1024intov_cur_undo_mbfromdba_data_fileswheretablespace_name=
v_undo_tbs_name
DBMS_OUTPUT.PUT_LINE('NOTE:Thefollowinganalysisisbaseduponthedatabaseworkloadduring
theperiod')
DBMS_OUTPUT.PUT_LINE('BeginTime:'||v_analyse_start_time)
DBMS_OUTPUT.PUT_LINE('EndTime:'||v_analyse_end_time)
DBMS_OUTPUT.PUT_LINE(CHR(9))
DBMS_OUTPUT.PUT_LINE('CurrentUndoConfiguration')
DBMS_OUTPUT.PUT_LINE('')
DBMS_OUTPUT.PUT_LINE(RPAD('Currentundotablespace',55)||':'||v_undo_tbs_name)
DBMS_OUTPUT.PUT_LINE(RPAD('Currentundotablespacesize(datafilesizenow)',55)||':'||
v_cur_undo_mb||'M')
DBMS_OUTPUT.PUT_LINE(RPAD('Currentundotablespacesize(considerautoextend)',55)||':'||
v_undo_tbs_size||'M')
IFV_UNDO_AUTOEXTTHEN
DBMS_OUTPUT.PUT_LINE(RPAD('AUTOEXTENDforundotablespaceis',55)||':ON')
ELSE
DBMS_OUTPUT.PUT_LINE(RPAD('AUTOEXTENDforundotablespaceis',55)||':OFF')
ENDIF
DBMS_OUTPUT.PUT_LINE(RPAD('Currentundoretention',55)||':'||v_undo_retention)
IFv_undo_guaranteeTHEN
DBMS_OUTPUT.PUT_LINE(RPAD('UNDOGUARANTEEissetto',55)||':TRUE')
ELSE
dbms_output.put_line(RPAD('UNDOGUARANTEEissetto',55)||':FALSE')
ENDIF
DBMS_OUTPUT.PUT_LINE(CHR(9))
SELECTinstance_numberINTOv_instance_numberFROMV$INSTANCE
DBMS_OUTPUT.PUT_LINE('UndoAdvisorSummary')
DBMS_OUTPUT.PUT_LINE('')
v_undo_advisor_advice:=dbms_undo_adv.undo_advisor(v_analyse_start_time,v_analyse_end_time,
v_instance_number)
DBMS_OUTPUT.PUT_LINE(v_undo_advisor_advice)
DBMS_OUTPUT.PUT_LINE(CHR(9))
DBMS_OUTPUT.PUT_LINE('UndoSpaceRecommendation')
DBMS_OUTPUT.PUT_LINE('')
v_undo_health_ret:=dbms_undo_adv.undo_health(v_analyse_start_time,v_analyse_end_time,
v_problem,v_recommendation,v_rationale,v_retention,v_utbsize)
IFv_undo_health_ret>0THEN
DBMS_OUTPUT.PUT_LINE('MinimumRecommendation:'||v_recommendation)
DBMS_OUTPUT.PUT_LINE('Rationale:'||v_rationale)
DBMS_OUTPUT.PUT_LINE('RecommendedUndoTablespaceSize:'||v_utbsize||'M')
ELSE
DBMS_OUTPUT.PUT_LINE('Allocatedundospaceissufficientforthecurrentworkload.')
ENDIF
SELECTdbms_undo_adv.best_possible_retention(v_analyse_start_time,v_analyse_end_time)into
v_best_retentionFROMdual
SELECTdbms_undo_adv.longest_query(v_analyse_start_time,v_analyse_end_time)into
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=omarzjxvc_341&id=1579035.1 2/4
21/6/2016 Document1579035.1
v_longest_queryFROMdual
SELECTdbms_undo_adv.required_retention(v_analyse_start_time,v_analyse_end_time)into
v_required_retentionFROMdual
DBMS_OUTPUT.PUT_LINE(CHR(9))
DBMS_OUTPUT.PUT_LINE('RetentionRecommendation')
DBMS_OUTPUT.PUT_LINE('')
DBMS_OUTPUT.PUT_LINE(RPAD('Thebestpossibleretentionwithcurrentconfigurationis',60)||'
:'||v_best_retention||'Seconds')
DBMS_OUTPUT.PUT_LINE(RPAD('Thelongestrunningqueryranfor',60)||':'||v_longest_query
||'Seconds')
DBMS_OUTPUT.PUT_LINE(RPAD('Theundoretentionrequiredtoavoiderrorsis',60)||':'||
v_required_retention||'Seconds')
END
/
SampleOutput
UndoAnalysisstartedat:30/08/201311:08:40
NOTE:Thefollowinganalysisisbaseduponthedatabaseworkloadduringtheperiod
BeginTime:23/08/201311:08:40
EndTime:30/08/201311:08:40
CurrentUndoConfiguration
Currentundotablespace:UNDOTBS2
Currentundotablespacesize(datafilesizenow):20M
Currentundotablespacesize(considerautoextend):20M
AUTOEXTENDforundotablespaceis:ON
Currentundoretention:900
UNDOGUARANTEEissetto:FALSE
UndoAdvisorSummary
Finding1:UndoTablespaceisunderpressure.Recommendation1:Sizeundotablespaceto26MB
UndoSpaceRecommendation
MinimumRecommendation:Sizeundotablespaceto26MB
Rationale:Increaseundotablespacesizesothatlongrunningquerieswill
notfail
RecommendedUndoTablespaceSize:26M
RetentionRecommendation
Thebestpossibleretentionwithcurrentconfigurationis:9171Seconds
Thelongestrunningqueryranfor:2543Seconds
Theundoretentionrequiredtoavoiderrorsis:2543Seconds
PL/SQLproceduresuccessfullycompleted.
RDBMSversion9iandbelow
Script
For9iandbelow,pleasedownloadthescript.
SampleOutput
UndoAnalysisstartedat:28/08/201311:03:23
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=omarzjxvc_341&id=1579035.1 3/4
21/6/2016 Document1579035.1
NOTE:Thefollowinganalysisisbaseduponthepeakdatabaseworkloadduringtheperiod
BeginTime:27/08/201321:56:36
EndTime:27/08/201322:06:36
Longestrunningqueryranfor::1368Seconds
Currentundoretentionis:900Seconds
Currentundotablespacesizeis:10M
AUTOEXTENDforundotablespacesizeis:ON
Recommendedundoretentionis:1369Seconds
Recommendedundotablespacesizeis:43M
UndoAnalysiscompletedat:28/08/201311:03:23
PL/SQLproceduresuccessfullycompleted.
REFERENCES
NOTE:877613.1AUMCommonAnalysis/DiagnosticScripts
NOTE:1580225.1WhatistheUndoAdvisorandhowtoUseitthroughtheDBMS_UNDO_ADVpackage
Didn'tfindwhatyouarelookingfor?
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=omarzjxvc_341&id=1579035.1 4/4