How can you diagnose and resolve ORA-01555 'snapshot too old' errors?
Jun 09, 2025 am 12:03 AMThe ORA-01555 error originates from the overwrite of the historical data required in the Oracle database consistency reading mechanism, which includes insufficient UNDO table space, long transaction interference, poor SQL execution efficiency and delayed block cleaning mechanism. 1. Check and expand the UNDO table space, enable automatic expansion or increase UNDO_RETENTION time; 2. Find and terminate transactions that have not been submitted for a long time to free UNDO resources; 3. Optimize the SQL statement execution plan, add appropriate indexes and process big data in batches; 4. Avoid executing large-scale queries immediately after large-scale DML operations, and manually refresh the buffer cache if necessary. The above measures can be effectively solved.
ORA-01555 is a common error in Oracle database, prompting "snapshot too old", which means that the query cannot obtain the rollback information required for consistent reads. Simply put, your query runs for too long and the old data it needs has been overwritten or cleaned.
Why does this error occur?
Oracle uses a consistent read mechanism to ensure that the query sees a consistent data snapshot. When a query is executed, it relies on information in the UNDO tablespace to rebuild past data versions. If this information is overwritten (for example, UNDO is reused after the transaction is committed), the query cannot continue, and an ORA-01555 error is thrown.
Check whether the UNDO tablespace size is reasonable
This is the most common reason. If the UNDO tablespace is too small, or the automatic expansion settings are unreasonable, long-running queries may not find enough historical data.
- Check the current UNDO tablespace usage :
SELECT a.tablespace_name, (SUM(a.bytes) / 1024 / 1024) AS "Total Size MB", (SUM(a.maxbytes) / 1024 / 1024) AS "Max Size MB" FROM dba_data_files a WHERE a.tablespace_name LIKE 'UNDOTBS%';
- Recommended operations :
- If you find that UNDO tablespaces are often close to full load, consider increasing their size or enabling automatic scaling.
- Set the appropriate
RETENTION
time, such as increasing theUNDO_RETENTION
parameter (units in seconds).
Check for long transaction interference
Sometimes, there are transactions that have not been submitted for a long time in the system, which will cause UNDO to be released in time, affecting other queries.
- Find the currently active transaction :
SELECT s.sid, s.serial#, t.xidusn, t.used_ublk, t.start_time FROM v$transaction t JOIN v$session s ON t.ses_addr = s.saddr;
- Suggested practices :
- Avoid doing too much in one transaction and commit as early as possible.
- If there is an exceptionally pending session, you can consider terminating to free UNDO resources.
Inadequate optimization of the query itself leads to excessive execution time
Sometimes the problem is not the database configuration, but the SQL statement itself is poorly efficient, resulting in the consistent read window being too long.
-
Common phenomena :
- Full table scanning has no index support
- Large number of sorting or hashing connections
- Lack of appropriate WHERE conditions to filter data
-
Recommended improvements :
- Check the execution plan and confirm whether there are performance bottlenecks
- Create appropriate indexes, especially fields for filtering and joining
- Processing large data volume result sets in batches
Enabled "delayed block clearing" mechanism may also cause this problem
In some cases, even if there are no long transactions, Oracle may cause the consistency view to be missing when performing delayed block clearing, triggering ORA-01555.
- This kind of scenario is relatively rare , but if you have just done large batches of DML operations (such as UPDATE, DELETE) and then run a large query, you may encounter this problem.
- Solution :
- Try to avoid executing large-scale queries immediately after DML
-
ALTER SYSTEM FLUSH BUFFER_CACHE;
(suitable for testing environments)
Basically, these common reasons and coping methods. Although this error may seem a bit scary, it can be effectively avoided most of the time just adjust the UNDO configuration, optimize SQL, or control the transaction lifecycle.
The above is the detailed content of How can you diagnose and resolve ORA-01555 'snapshot too old' errors?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The logical structure of Oracle database focuses on how data is organized by users and developers, including tables, views, patterns and table spaces; the physical structure involves the actual storage of data on disk, including data files, redo logs, control files, etc. 1. The logical structure includes tables, views, indexes, patterns and table spaces, which determine how users access data; 2. The physical structure consists of data files, redo logs, control files and archive logs, which are responsible for the persistence and recovery of data; 3. The table space is a key bridge connecting logic and physics, and its capacity is limited by the underlying data files; 4. Different roles have different levels of attention, developers focus on logic optimization, and DBA pays more attention to physical management; 5. Understanding the differences between the two can help efficiently troubleshoot problems, optimize performance and reasonable management

PL/SQLextendsSQLwithproceduralfeaturesbyaddingvariables,controlstructures,errorhandling,andmodularcode.1.Itallowsdeveloperstowritecomplexlogiclikeloopsandconditionalswithinthedatabase.2.PL/SQLenablesthedeclarationofvariablesandconstantsforstoringinte

AutomaticStorageManagement(ASM)isOracle’sbuilt-instoragesolutiondesignedtosimplifyandoptimizethemanagementofdatabasestorage.1.IteliminatestheneedforexternalvolumemanagersorRAIDconfigurations.2.ASMautomaticallybalancesI/Oacrossdisks,preventinghotspots

OracleDataGuard supports three standby databases: physical, logical, and snapshot. 1. The physical standby database is a byte-level copy of the main library, synchronized using RedoApply, suitable for disaster recovery; 2. The logical standby database applies changes through SQLApply, which can be structured different from the main library, suitable for reporting and selective replication; 3. The snapshot standby database is based on physical standby and can be converted into a writable state for testing, and FlashbackDatabase needs to be enabled. Select according to requirements: requires data consistency and quick switching of physics, requires flexibility and support for report selection logic, and select snapshots if you need to test the production environment copy.

InPL/SQL,exceptionsarecategorizedintotwotypes:predefinedanduser-defined.1.Predefinedexceptionsarebuilt-inerrorssuchasNO_DATA_FOUND,TOO_MANY_ROWS,VALUE_ERROR,ZERO_DIVIDE,andINVALID_NUMBER,whichareautomaticallyraisedduringspecificruntimeerrors.2.User-d

SubqueriesinOracleSQL—scalar,multi-row,andcorrelated—enhancequeryflexibilitybyenablingmodularlogic,dynamicdatahandling,andcomplexfiltering.Scalarsubqueriesreturnasinglevalueandareidealforcomparisonsorexpressionssuchascomputingtheaveragesalary;1.theys

Oracle sequences are independent database objects used to generate unique values ??across sessions and transactions, often used for primary keys or unique identifiers. Its core mechanism is to generate a unique value through NEXTVAL increment, and CURRVAL obtains the current value without incrementing. Sequences do not depend on tables or columns, and support custom start values, step sizes and loop behaviors. Common scenarios during use include: 1. Primary key generation; 2. Order number; 3. Batch task ID; 4. Temporary unique ID. Notes include: transaction rollback causes gaps, cache size affects availability, naming specifications and permission control. Compared to UUID or identity columns, sequences are suitable for high concurrency environments, but they need to be traded down based on the needs.

In Oracle, the schema is closely associated with the user account. When creating a user, the same-name mode will be automatically created and all database objects in that mode are owned. 1. When creating a user such as CREATEUSERjohn, create a schema named john at the same time; 2. The tables created by the user belong to their schema by default, such as john.employees; 3. Other users need authorization to access objects in other schemas, such as GRANTSELECTONsarah.departmentsTOjohn; 4. The schema provides logical separation, used to organize data from different departments or application modules.
