ORA-01555: snapshot too old in Oracle Database is a very common and critical performance issue faced by DBAs in production.
🔴 What ORA-01555 Means
👉 Oracle cannot reconstruct the older version of data needed by a query.
In simple terms:
Your query is running too long, and the required undo data has already been overwritten.
📌 Why This Happens
Oracle uses UNDO tablespace to maintain read consistency.
When a long-running query needs old data:
-
Oracle reads from UNDO
-
If UNDO is overwritten → ❌ ORA-01555
🔎 Common Causes
1️⃣ Long Running Queries
-
Query runs for a long time
-
Needs older data snapshot
2️⃣ Small UNDO Tablespace
-
Not enough space to retain old data
3️⃣ High DML Activity
-
Frequent INSERT / UPDATE / DELETE
-
Overwrites undo quickly
4️⃣ Commit Inside Loop (Very Common)
Bad code example:
FOR i IN 1..10000 LOOP
UPDATE emp SET sal = sal + 100 WHERE empno = i;
COMMIT;
END LOOP;
👉 This causes undo to be overwritten quickly.
5️⃣ Undo Retention Too Low
Check:
SHOW PARAMETER undo_retention;
🛠 Solutions
✅ 1️⃣ Increase UNDO Tablespace
ALTER DATABASE DATAFILE '/u01/undo01.dbf'
RESIZE 5G;
OR add new file:
ALTER TABLESPACE undotbs1
ADD DATAFILE '/u01/undo02.dbf' SIZE 2G;
✅ 2️⃣ Increase UNDO_RETENTION
ALTER SYSTEM SET undo_retention = 1800;
👉 (Value in seconds = 30 minutes)
✅ 3️⃣ Avoid Frequent Commits
❌ Wrong:
COMMIT inside loop
✅ Correct:
COMMIT after batch processing
✅ 4️⃣ Optimize Long Queries
-
Add indexes
-
Avoid full table scans
-
Break large queries into smaller chunks
✅ 5️⃣ Use RETENTION GUARANTEE (Advanced)
ALTER TABLESPACE undotbs1 RETENTION GUARANTEE;
⚠️ Use carefully → may block DML if space runs out.
🔎 Useful Monitoring Queries
Check undo usage
SELECT * FROM v$undostat;
Check undo tablespace size
SELECT tablespace_name, sum(bytes)/1024/1024 MB
FROM dba_data_files
WHERE tablespace_name LIKE 'UNDO%'
GROUP BY tablespace_name;
Check active long queries
SELECT sid, serial#, sql_id, elapsed_time
FROM v$session_longops
WHERE sofar != totalwork;
📊 Real Production Scenario
-
A report query runs for 1 hour
-
Meanwhile heavy transactions run
-
Undo gets overwritten
-
Query fails with:
ORA-01555: snapshot too old
✅ Real Fix Implemented
1️⃣ Increased UNDO tablespace
2️⃣ Increased undo_retention
3️⃣ Optimized report query
4️⃣ Scheduled job during low load
📘 Key DBA Learning
👉 ORA-01555 is usually a combination of:
-
Long query +
-
Insufficient undo +
-
High DML activity
⭐ Best Practices
✔ Size UNDO properly
✔ Avoid commit inside loops
✔ Monitor long queries
✔ Tune SQL
✔ Schedule heavy jobs off-peak
Reference - ChatGpt
🚀 𝐂𝐚𝐥𝐥𝐢𝐧𝐠 𝐚𝐥𝐥 𝐀𝐈 𝐞𝐱𝐩𝐞𝐫𝐭𝐬!
Be part of an exciting journey into the world of AI at Sangam AI Yatra 2026.
Are you passionate about AI and eager to share your insights with a vibrant community of technology professionals? This is your opportunity to take the stage, share your experience, and inspire the next wave of innovation.
Sangam AI Yatra 2026 will travel across five dynamic cities across India, bringing together leaders, architects, developers, and practitioners from AI, Cloud, Data, and Applications. Together, we will explore the latest trends, real-world use cases, and best practices shaping the future of technology.
🎤 𝐂𝐚𝐥𝐥 𝐟𝐨𝐫 𝐒𝐩𝐞𝐚𝐤𝐞𝐫𝐬 𝐢𝐬 𝐧𝐨𝐰 𝐨𝐩𝐞𝐧!
We invite AI experts, architects, innovators, and thought leaders to submit their Call for Papers and contribute to this powerful community-driven event.
✨ Why speak at Sangam?
• Share your knowledge with thousands of tech professionals
• Inspire the community with real-world innovation
• Connect with industry leaders and practitioners
• Help shape the future of AI and cloud technologies
🔗 Submit your session here:
https://lnkd.in/eGiU-qQf
Let’s bring the community together again and ignite the Oracle and AI passion across India. 🔥
hashtag#SangamAIYatra2026 hashtag#AICommunity hashtag#OracleCommunity hashtag#Cloud hashtag#AI hashtag#TechCommunity hashtag#CallForSpeakers Oracle Oracle AI Database Oracle Cloud Google Cloud Microsoft Azure Amazon Web Services (AWS)