码迷,mamicode.com
首页 > 其他好文 > 详细

ORA-01555

时间:2015-04-28 19:00:49      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:oracle   ora   

一.发现ORA-01555

Mon Dec 26 10:08:22 2011

ORA-01555 caused by SQL statement below (Query Duration=49146 sec, SCN: 0x0b4b.17f5ae42):

Mon Dec 26 10:08:22 2011

SELECT COMPANY_ID,

       COMPANY_MOBILE,

       TO_CHAR(NVL(REG_DATE, SYSDATE - 100),‘yyyymmddhh24miss‘),

       BAK_FIELD2

  FROM TAB_XN_COMPANY

 WHERE (COMPANY_STATUS = 1 OR

       (COMPANY_STATUS = 3 AND

       NVL(UNREG_DATE, SYSDATE + 100) >=

       TO_DATE(‘20111226094500‘,‘yyyymmddhh24miss‘)))

   AND NVL(REG_DATE, SYSDATE - 100) <=

       TO_DATE(‘20111226095959‘,‘yyyymmddhh24miss‘)

   AND PAY_TYPE > 0

二.数据库状态

[oracle@ora02 ~]$ sqlplus"/ as sysdba"

 

SQL*Plus: Release 9.2.0.4.0 - ProductiononWed Jan 4 10:48:17 2012

 

Copyright (c) 1982, 2002, Oracle Corporation. Allrights reserved.

 

 

Connectedto:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

Withthe Partitioning, OLAPandOracle Data Mining options

JServer Release 9.2.0.4.0 - Production

 

SQL> show parameter undo;

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

undo_management                      string      AUTO

undo_retention                      integer     10800

undo_suppress_errors                 boolean    FALSE

undo_tablespace                      string      UNDOTBS1

 

SQL>selectsum(maxbytes)/1024/1024/1024,

   2SUM(USER_BYTES)/1024/1024/1024FROMdba_data_fileswheretablespace_NAME=‘UNDOTBS1‘;

 

SUM(MAXBYTES)/1024/1024/1024SUM(USER_BYTES)/1024/1024/1024

---------------------------- ------------------------------

                  61.9999847                     32.6834106

 

SQL>SELECTDISTINCTSTATUS"状态",

  2                 COUNT(*)"EXTENT数量",

  3                 SUM(BYTES) / 1024 / 1024 / 1024"UNDO大小"

  4   FROMDBA_UNDO_EXTENTS

  5  GROUPBYSTATUS;

 

状态      EXTENT数量   UNDO大小

--------- ---------- ----------

ACTIVE             1 .000976563

EXPIRED         2549 31.2333298

UNEXPIRED          3 .000175476

通过undo_retention保留时间为10800秒,而该sql执行了49146秒,在这49146秒钟,TAB_XN_COMPANY表中 的数据被修改,而且被修改的undo数据在10800秒后被覆盖导致,导致原查询语句不能获取到scn小于或者等于查询时候的数据块内容(在undo 中),所以出现ORA-01555。从这里也可以看出来,在undo空间还剩余的情况下,如果超过了undo_retention限制,undo内容还是 有可能被覆盖,而不是使用未使用的undo

三.出现ORA-1555原因
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.
就是一个查询要访问某个数据块,而这个数据块在这个查询执行过程中修改过,那么该查询需要查询undo中数据块,而undo中该数据块已经不存在,从而出现ORA-1555

四.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)扫描执行一遍,或者收集全部统计信息


本文出自 “李鹏飞oracle” 博客,请务必保留此出处http://lipengfei666666.blog.51cto.com/6384154/1639675

ORA-01555

标签:oracle   ora   

原文地址:http://lipengfei666666.blog.51cto.com/6384154/1639675

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!