Rollback Segment Configuration & Tips [ID 69464.

1] Modified 21-OCT-2010 Type BULLETIN Status PUBLISHED

ROLLBACK SEGMENT CONFIGURATION & TIPS ====================================== Good rollback segment configuration is crucial to a well tuned Oracle database. The following should help you recognize and solve problems arising from inappropriate numbers or sizes of rollback segments. This bulletin will answer the following questions for Oracle databases prior to use of Automatic Undo Managment (AUM) with Oracle9i and Oracle10g: -What is a Rollback Segment? -How many concurrent transactions can a rollback segment handle? -How do you find out the max extents for a rollback segment? -How do you determine which user is using what rollback segment? -How does Oracle determine which rollback segment to use? -Why the ORA-1555 snapshot too old problem? -How many rollback segments you need to have? -How do you look for a rollback segment contention? -How do you decide the size of your rollback segments? -What are the guidelines on setting the OPTIMAL parameter for rollback segments? -How do you allocate a rollback segment for a transaction? -How do you bring rollback segments on line automatically?

What is a Rollback Segment ? ============================ A rollback segment is made up of multiple extents that consist of several 'rollback entries' which keeps undo information for transactions. Rollback segments are needed for:

3. Database recovery. The first block of the rollback segment is called the segment header. Read-consistant database information. The transaction table contains slots (or rows) which keep track of all active transactions within that rollback segment. * Before 7. Each active transaction assigned to this rollback segment will also have a corresponding slot or row assigned to it in the transaction table. STATUS.3 For example. more slots or rows can be inserted into the transaction table.1. How many transactions can a rollback segment handle concurrently ? ================================================================== The maximum number of transactions allowed for a rollback segment is dependent on the 'transaction table slots' found in the header of the rollback segment. Thereby. with a larger Oracle block size there is more room for a larger transaction table. 2. on Solaris: TRANSACTIONS -----------32 69 142 * For 7.3 BLOCKSIZE --------2K 4K 8K Also for Solaris : TRANSACTIONS -----------31 67 140 BLOCKSIZE --------2K 4K 8K How do you find out the maximum extents for a rollback segment? =============================================================== Run the following query: sql> select SEGMENT_NAME. The segment header contains a structure called a transaction table. MAX_EXTENTS . The extent map is also kept in the segment header. Rolling back uncommitted transactions. In other words.

terminal FROM v$lock l. p. NVL (p.id1(+)/65536) = r.paddr = p. 2.spid "SYSTEM PID ".pid "ORACLE PID".addr AND TRUNC (l. This is a common extent mapping GREATEST MAXEXTENT VALUE -----------------------25 57 121 249 505 Thereby.from dba_rollback_segs. the first each extent.sid(+) AND s. 'NO TRANSACTION') "OS How does Oracle determine which rollback segment to use? ======================================================== The rules are: 1. How to determine which user is using what rollback segment? =========================================================== SELECT USER". If two or more rollback segments have the same "least number of active txns" .lmode(+) = 6 ORDER BY "RB NAME ". p. r. Always assign to the rollback segment which has the least number of active transactions. Why the ORA-1555 snapshot too old problem? .type(+) = 'TX' AND v$process p.username.sid = s. The maximum number database block size of each table: DATA BLOCK SIZE --------------512 1K 2K 4K 8K the MAX_EXTENTS that the rollback segment was block of each segment contains an extent map for of extents allowed is therefore a function of the extent map entry.usn AND l. This will tell you created with. v$session s WHERE l. p. however. This ensures that undo is kept for a longer time. then assign to the one which is after the last one used. the MAX_EXTENTS value in "dba_rollback_segs" may not be accurate because the MAX_EXTENTS cannot exceed the GREATEST MAXEXTENT VALUE. v$rollname r.

40689. v$rollname n 3> where s. Another way to find out is by running the following query . waits 2> from v$rollstat s.========================================== See Note.usn=n. NAME WAITS -----------------------------. SVRMGR> select name. Example: SVRMGR> select * from v$waitstat. How do you find out a transaction table contention? =================================================== Any non-zero value for 'undo header' in the CLASS column of "v$waitstat" indicates contention for rollback segment header blocks. CLASS -----------------data block sort block save undo block segment header save undo header free list system undo header system undo block undo header undo block COUNT ---------0 0 0 0 0 0 0 0 0 0 TIME ---------0 0 0 0 0 0 0 0 0 0 Note that 'undo header' value is zero. hence NO contention.1: ORA-1555 "SNAPSHOT TOO OLD" in Very Large Databases (VLDB).usn. a non-zero value for the 'WAITS' column indicates a rollback segment contention.1: CAUSES AND SOLUTIONS TO ORA-1555 "SNAPSHOT TOO OLD".---------- . Every transaction must have update access to the transaction table for its rollback segment. You need enough rollback segments to prevent transactions contending for the transaction table. See Note. How MANY rollback segments do you need to have? =============================================== Oracle7 keeps a transaction table in the header of every rollback segment.45895..

so not all active users will have to have many short transactions). How do you decide what SIZE your rollback segments should be? ============================================================= There are two issues that need to be considered when deciding if your segment is large enough. you need to know how many be active at any given time. Determining the proper rollback segment size: --------------------------------------------The size needed for a rollback segment depends directly on the transaction activity of your database.SYSTEM R01 R02 R03 0 0 0 0 To calculate the number of transactions are likely to what users are doing. you want to make sure that the rollback segment doesn't wrap around and prevent the construction of a read consistent view (look at "Why the ORA-1555 snapshot too old problem?" above). First. Note that access. For BATCH jobs : One rollback segment for each concurrent job. We will deal with these special cases separately. This causes the segment to extend in size. Second. you want to make sure that the transactions will not cause the head of the rollback segment to wrap around too fast and catch the tail. Oracle strongly recommend that each . if you have long running queries that access data that frequently changes. Same size extents: -----------------For sizing rollback segments extents. This depends on queries do not need transaction table active transactions (OLTP applications tend General recommendation for how many rollback segments: For OLTP : One rollback segment for every ten users. rollback segments. You need to be concerned about the activity during normal processing of the database. not with rare or semi-frequent large transactions.

Create the rollback segments so that all extents are the same size. Each rollback segment should start with two extents before the test is done. To find out the size of the rollback segments needed to handle normal processing on the database you need to some testing. 5. This is the minimum number of extents any rollback segment can have.extent be of the same size. A good test is to start with small rollback segments and allow your application to force them to extend. NEXT extent size: ----------------Use the same value for NEXT as INITIAL. etc. 2.. 16KB. INITIAL extent size: -------------------Choose the INITIAL storage parameter from the list 2KB. Create a rollback segment tablespace. Choose an extent size that you will suspect will need between 10 to 30 extents when the segments grow to full size. 3. MINEXTENTS: ----------Set MINEXTENTS to 20. 4. . Activate only the rollback segments that you are testing by making the status "online". This will insure that when you drop the extent you can reuse all the freed space without waste. this will make it unlikely that the rollback segment needs to grab another extent because the extent that should move into is still being used by an active transaction. The only other segment that should be "online" is the system rollback segment. Here are the steps to run such test: 1. 8KB. 32KB .. 4KB. Select a number of rollback segments to test and create them in the tablespace.

adjust the number of the rollback segments (increase) and rerun the test. There are basically two options that you can choose from for your rollback segment tablespace. Watch for rollback segment contention. if the largest size requires fewer than 10 or more than 30. there is a straightforward way to configure the tablespace: Create a tablespace that will fit your calculated number of rollback segments with the "minimum coverage size" you have determined. Follow the guidelines above for INITIAL and NEXT extents. As a safety net. use the OPTIMAL feature to force the rollback segments to free up any additional space they allocate beyond their determined size requirement. Run transactions and load data typical of the application. How to find out? 8. Sizing rollback segments for FREQUENT LARGE transaction rate: ------------------------------------------------------------A large transaction is one in which there is not enough space to create all rollback segments of the size necessary to handle its rollback information. If you select to do this. . Since we can't depend on the segment shrinking in time to allow repeated large transactions. Watch for the maximum size a rollback extends to. it is a good idea to lower or raise the extent size. Sizing rollback segments for STEADY AVERAGE transaction rate: ------------------------------------------------------------For databases where the transaction rate base has NO fluctuation. OPTIMAL is not really an option for this environment. The maximum size any one of the rollback segments reaches during the test is the size you want to use when configuring.6. We will call this size the "minimum coverage size." If you see rollback contention. allocate some additional space in the tablespace to allow segments to grow if necessary. respectively. and rerun the test. 7. Also.

This option will introduce contention and will cause some degradation in performance. but the segment will release the space before the next large transaction comes along. B) Build one or more large rollback segments and make sure that large transactions use these segments.A) Reduce the number of segments so that all are large enough to hold the largest transactions. Sizing rollback segments for INFREQUENT LARGE transaction rate: --------------------------------------------------------------Use the OPTIMAL feature to set up a flexible rollback segment scheme. This option is difficult to implement if large transactions are being run with adhoc queries and there is no systematic control of large transactions. create the rollback tablespace with the space needed for your calculated number of segments and their "minimum coverage size" plus this additional space. The key is to leave enough free space in the rollback tablespace that the largest transaction's rollback information can fit entirely into it. an application which will set the transaction to the appropriate rollback segment. To do this. The SET TRANSACTION USE ROLLBACK SEGMENT command is necessary to control the placement of these large transactions. In other words. This option is recommended in an environment where the large transactions are issued from a controlled environment. Set the OPTIMAL for each segment equal to the minimum coverage size. What are the guidelines on setting the OPTIMAL parameter for rollback segments? ======================================================================= ======== When you create or alter a rollback segment. one in which you are not concerned about which rollback segment the large transaction falls upon. What you will see is that the large transaction will randomly make one of the segments grow and consume the free space. you can use the storage parameter OPTIMAL. Note that you are sacrificing some performance for this flexibility. It is a reasonable choice if performance is not extremely critical. to specify the . which applies only to rollback segments.

statement must be the first statement of the transaction. After the transaction is committed.ora initialization parameter rollback_segments. Oracle will automatically assign the next transaction to any available rollback segment rollback segment unless the new transaction is explicitly assigned to a specific rollback by the user. For a system that executes long running transactions frequently. OPTIMAL should be smaller for a system that mainly executes short transactions and queries so that the rollback segments remain small enough to be cached in memory. Otherwise.. OPTIMAL should be large so that Oracle does not have to shrink and allocate extents frequently. Example : SET TRANSACTION USE ROLLBACK SEGMENTS large_rs1. performance will suffer due to excessive segment resizing. thus improving system performance.. You should not make OPTIMAL smaller than the "minimum coverage size". How do you bring rollback segments on line automatically? ========================================================= Private rollback segments could be brought online automatically at database startup only if they are listed in the init. for a system that executes long queries on active database. To assign a transaction to a rollback segment explicitly. Also. the rollback segment must be online and the SET TRANSACTION . How do you allocate a rollback segment for a transaction? ========================================================= Oracle assigns a transaction to a rollback segment using simple rules. You should carefully assess the kind of transactions the system runs when setting the OPTIMAL parameter for each rollback segment. You can issue a SET TRANSACTION statement with the USE ROLLBACK SEGMENT clause to choose a specific rollback segment for your transaction. OPTIMAL should be large to avoid "snapshot too old" ORA-1555 errors.optimal size of the rollback segment in bytes. .

The minum number of public rollback segments acquired by the instance will be transactions/transactions_per_rollback_segments. segments . Search Words: ============= rbs. Public rollback segments could also be brought online specifying them in the parameter rollback_segments. rollback.The number of public rollback segments that will be brought online only at database startup will depend on the values of the initialization parameters transactions and transactions_per_rollback_segments.

Sign up to vote on this title
UsefulNot useful