简体   繁体   中英

SQL--— Error when trying to export query results as CSV

I am running a large query (6 million records) which has a lot of INNER JOINS with other tables but when I am trying to export the query results on CSV I am getting the following results. I googled it for a while but could not get any result.

ORA-01555: snapshot too old: rollback segment number 69 with name
"_SYSSMU69_2356811035$" too small
ORA-0263: "snapshot too old: rollback segment number %s with name \"%s\" too small" 
*Cause: rollback records needed by a reader for consistent read are overwritten by other writers
*Action:  If in Automatic Undo Management mode, increase undo_retention setting. Otherwise, rollback segments 
Vendor code 1555

Let me explain you what happens. When Oracle executes a query, the result of the query, no matter how much time the query takes, must be consistent with the picture of that data at the moment the query was initiated.

The ORA-1555 errors can happen when a query is unable to access enough undo to build a copy of the data at the time the query started. Committed "versions" of blocks are maintained along with newer uncommitted "versions" of those blocks so that queries can access data as it existed in the database at the time of the query. These are referred to as "consistent read" blocks and are maintained using Oracle undo management.

This consistency is handled by the UNDO tablespace. In your case, the most probable scenario is the following:

  • The query that runs the csv is started at one moment in time. Oracle runs the query to get the 6 million rows that were in those tables at that moment in time.
  • During the execution of the query, several other processes are running DML operations against the affected records, therefore the data that was before is moved to the UNDO tablespace ( Rollback segments is the type of the segments stored on the UNDO tablespace )
  • However, if your undo is small or your undo_retention is not enough, in order to preserve the integrity of the database, Oracle will overwrite those rollback segments with new ones if there is no enough space on that tablespace.

Try the following things:

  • Increase undo tablespace
  • Increase undo_retention parameter.

There are a plethora of bugs in old Oracle versions related with ORA-1555, and other possibilities when undo data are lob segments, etc.. If you have access to Support, here you will find the master note

ORA-1555 Master Note

ORA-1555 Diagnosis and Troubleshooting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM