Legal | Privacy

Automatically Managing Undo

Purpose

This module describes how Oracle Database 10g automates the management of undo.

Topics

This module discusses the following:

Overview
Prerequisites
Creating an Undo Tablespace
Using the Tablespace for Undo Retention
Generating Some Activity
Reviewing Undo Advisor Recommendations

Place the cursor on this icon to display all screenshots. You can also place the cursor on each icon to see only the screenshot associated with it.

Overview

To simplify management of rollback segments, the Oracle9i database introduced Automatic Undo Management (AUM) where the database automatically manages allocation and management of undo (rollback) space among various active sessions. In a database using AUM, all transactions share a single undo tablespace. Any executing transaction can consume free space in this tablespace. Undo space is dynamically transferred from committed transactions to executing transactions in the event of space scarcity in the undo tablespace..The AUM feature also provides a way for administrators to exert control on undo retention. You can specify the amount of undo to be retained in terms of wall clock time (number of seconds). With retention control, you can configure your systems to allow long running queries to execute successfully without encountering ORA-1555 (Snapshot too old) errors..The undo retention time is specified using a new persistent initialization parameter, UNDO_RETENTION. This parameter is dynamic and hence can be changed anytime during database operation using the ALTER SYSTEM command.

The AUM feature is further enhanced in Oracle Database 10g by providing Automatic Undo Retention Tuning. This feature is used by default, and it automatically determines the optimal undo retention time depending on the size of the undo tablespace. Without your intervention, the Oracle Database 10g dynamically adjusts to the change in undo requirements depending on the system activity. This maximizes the usage of the available space in the undo tablespace and allows long running queries to complete without encountering any “Snapshot Too Old” errors provide your undo tablespace is big enough.

In this lesson, you will intentionally switch to a small undo tbs, and although you use automatic undo retention tuning, you will encounter 1555 because the undo tbs is too small. In which case you need the undo advisor to compute the right size that depends on the workload.

Before starting this module, you should have:

1.

Completed the Configuring Linux for the Installation of Oracle Database 10g lesson

2.

Completed the Installing the Oracle Database 10g on Linux lesson

3.

Download and unzip undoadv.zip into your working directory (i.e. /home/oracle/wkdir)

To create an undo tablespace in Enterprise Manager, perform the following

1.

Open your browser and enter the following URL:

http://localhost:5500/em

Enter sys/<password> and specify SYSDBA then click Login.

Move your mouse over this icon to see the image

 

2.

Click on the Administration tab.

Move your mouse over this icon to see the image

 

3.

Click on the Tablespaces link.

Move your mouse over this icon to see the image

 

4.

Click Create.

Move your mouse over this icon to see the image

 

5.

Enter UT1 for the name, click on the Type Undo and click Add to add a datafile.

Move your mouse over this icon to see the image

 

6.

Enter ut1.dbf for the filename and 400KB for the file size and click Continue.

Move your mouse over this icon to see the image

 

7.

Click OK.

Move your mouse over this icon to see the image

 

8.

Your undo tablespace was created. Now you can enable undo retention tuning. Click your Database breadcrumb.

Move your mouse over this icon to see the image

 

Now you can use the tablepsace you just created. Perform the following:

1.

Click on Undo Management.

Move your mouse over this icon to see the image

 

4.

Click Change Tablespace.

Move your mouse over this icon to see the image

 

5.

Select the radio button next to UT1 and click OK.

Move your mouse over this icon to see the image

 

6.

The undo tablespace has been changed to the one you just created. Now you are ready to see how it works.

Move your mouse over this icon to see the image

 

To see how undo management is handled, you need to generate some activity. Perform the following:

1.

You will first need to determine the date and time of your database. Open a terminal window and enter the following commands:

cd wkdir
sqlplus /nolog
connect / as sysdba;
@datetime

The datetime.sql script looks as follows:

select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS') 
 from dual;

Move your mouse over this icon to see the image

 

2.

From the same session, execute the following command:

@newtable

The newtable.sql script looks as follows:

create table newtable(b int, s varchar2(100));
begin
for i in 1..100 loop
insert into newtable values(i, rpad('s', 100));
end loop;
commit;
end;
/

Move your mouse over this icon to see the image

 

3.

From the first session, execute the following:

@uscript1

The uscript1.sql script looks as follows:

declare
b number;
cursor c1 is select b from newtable;
begin
open c1;
loop
fetch c1 into b;
dbms_lock.sleep(6);
exit when c1%notfound;
end loop;
close c1;
commit;
end;
/

Move your mouse over this icon to see the image

 

4.

Open another terminal window and execute the following commands:

cd wkdir
sqlplus /nolog
connect / as sysdba
@uscript2

The uscript2.sql script looks as follows:

begin
for i in 1..1000 loop
update newtable set b=b+1, s=rpad('t', 100);
commit;
end loop;
end;
/

Move your mouse over this icon to see the image

 

5.

Switch back to the first SQL*Plus session. Soon, you get a "Snapshot too old" error. Although you are using Automatic Undo Retention tuning, your undo tablespace is too small to accommodate the update script.

Move your mouse over this icon to see the image

 

To review the recommendations that the undo advisor made, perform the following:

1. Switch back to Enterprise Manager and look at the Undo Management page. Notice that the current recommendation (61MB) is because the default analysis is for the past seven days. Since you want to analyze a particular workload, and not what had happened before you will need to customize the time period. Select the Customized Time Period for the Analysis Time Period and click Update Analysis.

Move your mouse over this icon to see the image

 

2.

Use the date and time you determined previously for the Period Starts field. For the Period Ends field, use the same value plus two hours. Once done, press the OK button.

Move your mouse over this icon to see the image

 

3.

You want perform the recommendation and raise the size of your undo tablespace. Click Edit Undo Tablespace.

Move your mouse over this icon to see the image

 

4.

Click Add to add a datafile.

Move your mouse over this icon to see the image

 

5.

Enter ut2.dbf as the filename and specify whatever the recommendation should be. Then click OK.

Move your mouse over this icon to see the image

 

6.

Click Apply.

Move your mouse over this icon to see the image

 

7.

Select your Database breadcrumb.

Move your mouse over this icon to see the image

 

8.

Select Undo Management.

Move your mouse over this icon to see the image

 

9.

You need to change the time period again. Select the Customized Time Period for the Analysis Time Period and click Update Analysis.

Move your mouse over this icon to see the image

 

10.

Change the date and time to the same as you did in step 2. Then click OK.

Move your mouse over this icon to see the image

 

11.

Notice that there are no problems or recommendations any longer. You may try running the uscript1 and uscript2 again to make sure the size of your tablespace is appropriate.

Move your mouse over this icon to see the image

Place the cursor on this icon to hide all screenshots.

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy