Home > Oracle Database / Applications Tips > Oracle database administrator > Optimize your undo parameters
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Optimize your undo parameters


Marco Gilbert
05.18.2004
Rating: -4.35- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


When you are working with UNDO (instead of ROLLBACK), there are two important things to consider:
  • The size of the UNDO tablespace
  • The UNDO_RETENTION parameter

There are two ways to proceed to optimize your resources.

  1. You can choose to allocate a specific size for the UNDO tablespace and then set the UNDO_RETENTION parameter to an optimal value according to the UNDO size and the database activity. If your disk space is limited and you do not want to allocate more space than necessary to the UNDO tablespace, this is the way to proceed.
  2. If you are not limited by disk space, then it would be better to choose the UNDO_RETENTION time that is best for you (for FLASHBACK, etc.). Allocate the appropriate size to the UNDO tablespace according to the database activity.
  3. This tip help you get the information you need whatever the method you choose. It was tested on Oracle9i (9.2.0.4, 9.2.0.5).

    set serverout on size 1000000
    set feedback off
    set heading off
    set lines 132
    declare
      cursor get_undo_stat is
             select d.undo_size/(1024*1024) "C1",
                    substr(e.value,1,25)    "C2",
                    (to_number(e.value) * to_number(f.value) *
    g.undo_block_per_sec) / (1024*1024) "C3",
                    round((d.undo_size / (to_number(f.value) *
    g.undo_block_per_sec)))             "C4"
               from (select sum(a.bytes) undo_size
                       from v$datafile      a,
                            v$tablespace    b,
                            dba_tablespaces c
                      where c.contents = 'UNDO' 
                        and c.status = 'ONLINE'
                        and b.name = c.tablespace_name
                        and a.ts# = b.ts#)  d,
                    v$parameter e,
                    v$parameter f,
                    (select max(undoblks/((end_time-begin_time)*3600*24))
    undo_block_per_sec from v$undostat)  g
              where e.name = 'undo_retention'
                and f.name = 'db_block_size';
    begin
    dbms_output.put_line(chr(10)||chr(10)||chr(10)||chr(10) || 'To optimize UNDO you have two choices :'); dbms_output.put_line('==================================================
    ==' || chr(10));
      for rec1 in get_undo_stat loop
          dbms_output.put_line('A) Adjust UNDO tablespace size according to UNDO_RETENTION :' || chr(10));
          dbms_output.put_line(rpad('ACTUAL UNDO SIZE ',65,'.')|| ' : ' ||
    TO_CHAR(rec1.c1,'999999') || ' MEGS');
          dbms_output.put_line(rpad('OPTIMAL UNDO SIZE WITH ACTUAL UNDO_RETENTION (' || ltrim(TO_CHAR(rec1.c2/60,'999999')) || ' MINUTES)
    ',65,'.') || ' : ' || TO_CHAR(rec1.c3,'999999') || ' MEGS');
          dbms_output.put_line(chr(10));
          dbms_output.put_line('B) Adjust UNDO_RETENTION according to UNDO tablespace size :' || chr(10));
          dbms_output.put_line(rpad('ACTUAL UNDO RETENTION ',65,'.') || ' : ' || TO_CHAR(rec1.c2/60,'999999') || ' MINUTES');
          dbms_output.put_line(rpad('OPTIMAL UNDO RETENTION WITH ACTUAL UNDO SIZE (' || ltrim(TO_CHAR(rec1.c1,'999999')) || ' MEGS) ',65,'.') || ' : ' || TO_CHAR(rec1.c4/60,'999999') || ' MINUTES');
      end loop;
    dbms_output.put_line(chr(10)||chr(10));
    end;
    /
    
    select 'Number of "ORA-01555 (Snapshot too old)" encountered since the last startup of the instance : ' || sum(ssolderrcnt)
      from v$undostat;
    

    Rate this Tip
    To rate tips, you must be a member of SearchOracle.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    Oracle database administrator
    Understanding SQL string functions
    What is the difference between a database engineer, architect and administrator?
    Import on one table from dump file
    Error during RMAN backup
    Can I drop a column in SYS schema?
    STATSPACK tool: transaction vs. execution measurement
    Should I port from Microsoft Access?
    How can I find statistics on total memory usage and database connections?
    Installing multiple Oracle homes
    Modifying SYS password in a RAC environment

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    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.



Oracle Development Solutions - SQL, J2EE, XML, SOA
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts