1. 程式人生 > >ORA-01555 caused by SQL statement below

ORA-01555 caused by SQL statement below

Alert.log今天產生大量的

ORA-01555 caused by SQL statement below (SQL ID: atfsm4urynvf2, Query Duration=0 sec, SCN: 0x0087.1d1eafdc):
select * from askey_id_mapping as of timestamp sysdate - 2/24 where ID_VALUE = ‘JCYVD30001655CN’
Sat Dec 08 10:43:43 2018
ORA-01555 caused by SQL statement below (SQL ID: cx70v53dbq51x, Query Duration=0 sec, SCN: 0x0087.1c7e4165):
select * from askey_id_mapping as of timestamp sysdate - 4/24 where ID_VALUE = ‘JCYVD30001655CN’
Sat Dec 08 10:44:14 2018
Thread 1 advanced to log sequence 377657 (LGWR switch)
Current log# 1 seq# 377657 mem# 0: +NSFC3DB_ARCH/nsfc3db/onlinelog/group_1.267.860580217
Sat Dec 08 10:44:15 2018

就是一個查詢要訪問某個資料塊,而這個資料塊在這個查詢執行過程中修改過,那麼該查詢需要查詢undo中資料塊,而undo中該資料塊已經不存在,從而出現ORA-1555。

解決辦法:
Case 1 – Rollback Overwritten
1.縮短sql執行時間
2.增加undo_retention,這個同時需要考慮undo空間大小
3.減少commit(rollback)次數
4.在一條sql中儘量使資料塊訪問一次
4.1)Using a full table scan rather than an index lookup
4.2)Introducing a dummy sort so that we retrieve all the data, sort it and then sequentially visit these data blocks.

Case 2 – Rollback Transaction Slot Overwritten
這種問題,主要是延遲塊清理導致,一般建議在進行大批量的dml操作後,使用全表(全index)掃描執行一遍,或者收集全部統計資訊

對於誤刪恢復資料:
select * from askey_id_mapping as of timestamp to_timestamp(‘2018-12-08 10:30:30’,‘yyyy-mm-dd hh24:mi:ss’)

查詢長事物:
select * from gv$transaction —check transaction number

-----------check transaction running time
set linesize 200
set pagesize 5000
col transaction_duration format a45

with transaction_details as
( select inst_id
, ses_addr
, sysdate - start_date as diff
from gvKaTeX parse error: Expected 'EOF', got '#' at position 416: ….sid , s.serial#̲ from gvsession s
, transaction_details t
where s.inst_id = t.inst_id
and s.saddr = t.ses_addr
order by t.diff desc
/