Mohamed Houri’s Oracle Notes

February 26, 2007

ORA-01555 and set transaction : another reason

Filed under: Ora-01555 — hourim @ 12:31 pm

Another reason that might cause ora-01555 to happen on rollback segment YYL_RB while we have explicitly set the transaction so that it will use the rollback segment XXL_RB can be explained by the beginning and the end of a transaction. When using the following command:


We have to ensure that this command is the first instruction of the transaction. Otherwise we will get the following error:

ORA-01453: SET TRANSACTION must be first statement of transaction

The question we have to ask is: when the transaction finishes? The transaction finishes when a commit or a rollback is issued. Thus, if you set your transaction to use rollback segment xxl_rb be aware that when you commit or you rollback, your transaction has finished and is no longer instructed to use xxl_rb rollback segment for its redo/undo. Be aware also that any DDL issued in your transaction such as truncate table marks the transaction as finished.

February 22, 2007

ORA-01555 and set transaction use rollback segment XXL_RB

Filed under: Ora-01555 — hourim @ 8:02 am

If you do not understand why you got a rollback segment snapshot too old on YYL_RB rollback segment in a transaction where you have explicitly instructed oracle to use the rollback segment XXL_RB, then read this ora-1555-and-set-transaction.pdf

February 8, 2007

How to avoid ora-01555 error

Filed under: Ora-01555 — hourim @ 12:14 pm

When dealing with oracle initial loads or with massif updates/deletes that generate undo (also known as rollback) and redo overheads, then the most frequent error in this context is the so famous ORA-01555: Rollback segment snapshot too old.

What also makes this error very frequent in many production applications is the data volume difference between test and production environments of those applications. Due to this data volume difference, the ORA-01555 error takes place most frequently in production were we are too late to change the logic and were it is so difficult to intervene.

This is why one of the obvious but very important solution to avoid this error is to have a real test environment with a leat the same data volume as it will be the case in production. Thus if the ORA-01555 error will have to happen, it will be pointed out much earlier in the development process making changes more flexible.

In On-Line Transaction Processing (OLTP) systems I have been faced with the ORA-01555 error in many cases. One of the main actions I realised I have to do in order to avoid it is to do not commit accross fetch (this is what many developers came to a long time before me).

Commit across fecth represents a commit inside a loop as shown here below:

FOR r_cur IN c_cur LOOP

-- Traitement is done here
 update/delete ....
 COMMIT; -- commit across fetch increases the odds of ora-01555

Thus in order to drastically decrease the odds of ORA-01555, commit outside the loop as shown below:

FOR r_cur IN c_cur LOOP
 -- Traitement is done here
 update/delete ....
 COMMIT; -- Commit is done here outside the loop

But commiting only once for the whole process will certainly contribute to avoid ORA-01555 error but may also increases the odds of its twin sister ORA-01562 : failed to extend rollback segment number string.

So that the probability of the occurence of both errors will decrease, the above plsql code are updated as follows:

 v_record_number NUMBER := 0;
 v_commit_val NUMBER := 500; -- commit when 500 records have been processed


LOOP -- main technical loop
 v_record_number := 0;

FOR r_cur IN c_cur LOOP

-- log the number of treated record
 v_record_number := v_record_number + 1;

-- Traitement is done here
 update/delete ....

-- Decide to commit
 IF v_record_number >= v_commit_val THEN


-- Cursor is closed automatically in the for loop
 COMMIT; -- commit outside the inner loop

EXIT WHEN v_record_number less than v_commit_val ;
 END LOOP; -- inner loop
 END; -- main technical loop</strong>

In any way, one thing you must absolutely consider is to make your process restartable. If not, then any ORA-01555 or ORA-01562 error will let updates done in the FOR loop cursor in a totally unknown state and will be considered as fatal.

Blog at

Tony's Oracle Tips

Tony Hasler's light hearted approach to learning about Oracle

Richard Foote's Oracle Blog

Focusing Specifically On Oracle Indexes, Database Administration and Some Great Music

Hatem Mahmoud Oracle's blog

Just another Oracle blog : Database topics and techniques

Mohamed Houri’s Oracle Notes

Qui se conçoit bien s’énonce clairement

Oracle Diagnostician

Performance troubleshooting as exact science

Raheel's Blog

Things I have learnt as Oracle DBA

Coskan's Approach to Oracle

What I learned about Oracle

So Many Oracle Manuals, So Little Time

“Books to the ceiling, Books to the sky, My pile of books is a mile high. How I love them! How I need them! I'll have a long beard by the time I read them”—Lobel, Arnold. Whiskers and Rhymes. William Morrow & Co, 1988.

Carlos Sierra's Tools and Tips

Tools and Tips for Oracle Performance and SQL Tuning

Oracle Scratchpad

Just another Oracle weblog


Dominic Brooks on Oracle Performance, Tuning, Data Quality & Sensible Design ... (Now with added Sets Appeal)