您的位置:首页 > 数据库 > Oracle

oracle数据泵导入分区表统计信息报错(三)

2013-05-22 11:33 232 查看
今天在进行数据泵导入操作时,发现一个bug。

前两篇文章分别介绍了问题的发现和深入,这篇文章检查问题和表的MONITORING属性之间的关系。

前不久检查了一篇以往的BLOG,意外的发现这个bug居然被我忘记了,时隔一年继续解决这个问题。

根据上一篇文章所介绍的分析过程,基本上可以确认和这几张分区表的统计信息本身有关。

由于当前数据库是从920环境EXP导出,IMP导入到同版本的中间数据库,最终通过数据泵IMPDP导入到当前数据库的。而分区表由于无法解决表空间的转换问题,因此在中间数据库手工创建,在IMP导入的时候指定了IGNORE=Y参数。

而现在恰好问题出在这个用户的所有分区表上,难道问题和迁移的过程有关系。检查了当时的脚本,没有发现异常之处。

不过由于原始数据的版本是9204,而迁移后的版本是10203,有可能是版本的不同导致了迁移过程中某些参数的设置发生了变化。

表的存储参数中与统计信息相关的就是MONITORING了。这个存储参数比较有意思,从9i开始引入,到了10g及以后版本中,这个参数又消失了。并不是Oracle认为这个参数没有意义而去掉了,而是Oracle认为这个MONITORING功能的代价很小,而对于统计信息十分有帮助,因此变成了Oracle的默认的行为,只留下了一个隐含参数来控制是否进行MONITORING的操作。

检查这几个表的MONITORING属性,发现值都是YES:

SQL> SELECT TABLE_NAME, MONITORING

2 FROM USER_TABLES

3 WHERE TABLE_NAME IN

4 (SELECT TABLE_NAME FROM USER_PART_TABLES);

TABLE_NAME MON

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

EMED_WEB_LOG YES

ORD_LOG_HIT_COMM YES

ORD_PURCHASE_ITEM YES

ORD_ORDER_ITEM YES

ORD_ORDER YES

CON_LOG_LIST_ITEM YES

已选择6行。

但是10g和9i的数据字典中MONITORING的值的来源是不同的,在9i中:

SQL> SELECT TEXT FROM DBA_VIEWS WHERE VIEW_NAME = 'DBA_TABLES';

TEXT

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

select u.name, o.name, decode(bitand(t.property, 4194400), 0, ts.name, null),

decode(bitand(t.property, 1024), 0, null, co.name),

decode((bitand(t.property, 512)+bitand(t.flags, 536870912)),

0, null, co.name),

decode(bitand(t.property, 32+64), 0, mod(t.pctfree$, 100), 64, 0, null),

decode(bitand(ts.flags, 32), 32, to_number(NULL),

decode(bitand(t.property, 32+64), 0, t.pctused$, 64, 0, null)),

decode(bitand(t.property, 32), 0, t.initrans, null),

decode(bitand(t.property, 32), 0, t.maxtrans, null),

s.iniexts * ts.blocksize,

decode(bitand(ts.flags, 3), 1, to_number(NULL),

s.extsize * ts.blocksize),

s.minexts, s.maxexts,

decode(bitand(ts.flags, 3), 1, to_number(NULL),

s.extpct),

decode(bitand(ts.flags, 32), 32, to_number(NULL),

decode(bitand(o.flags, 2), 2, 1, decode(s.lists, 0, 1, s.lists))),

decode(bitand(ts.flags, 32), 32, to_number(NULL),

decode(bitand(o.flags, 2), 2, 1, decode(s.groups, 0, 1, s.groups))),

decode(bitand(t.property, 32), 32, null,

decode(bitand(t.flags, 32), 0, 'YES', 'NO')),

decode(bitand(t.flags,1), 0, 'Y', 1, 'N', '?'),

t.rowcnt,

decode(bitand(t.property, 64), 0, t.blkcnt, null),

decode(bitand(t.property, 64), 0, t.empcnt, null),

t.avgspc, t.chncnt, t.avgrln, t.avgspc_flb,

decode(bitand(t.property, 64), 0, t.flbcnt, null),

lpad(decode(t.degree, 32767, 'DEFAULT', nvl(t.degree,1)),10),

lpad(decode(t.instances, 32767, 'DEFAULT', nvl(t.instances,1)),10),

lpad(decode(bitand(t.flags, 8), 8, 'Y', 'N'),5),

decode(bitand(t.flags, 6), 0, 'ENABLED', 'DISABLED'),

t.samplesize, t.analyzetime,

decode(bitand(t.property, 32), 32, 'YES', 'NO'),

decode(bitand(t.property, 64), 64, 'IOT',

decode(bitand(t.property, 512), 512, 'IOT_OVERFLOW',

decode(bitand(t.flags, 536870912), 536870912, 'IOT_MAPPING', null

))),

decode(bitand(o.flags, 2), 0, 'N', 2, 'Y', 'N'),

decode(bitand(o.flags, 16), 0, 'N', 16, 'Y', 'N'),

decode(bitand(t.property, 8192), 8192, 'YES',

decode(bitand(t.property, 1), 0, 'NO', 'YES')),

decode(bitand(o.flags, 2), 2, 'DEFAULT',

decode(s.cachehint, 0, 'DEFAULT', 1, 'KEEP', 2, 'RECYCLE', NULL)),

decode(bitand(t.flags, 131072), 131072, 'ENABLED', 'DISABLED'),

decode(bitand(t.flags, 512), 0, 'NO', 'YES'),

decode(bitand(t.flags, 256), 0, 'NO', 'YES'),

decode(bitand(o.flags, 2), 0, NULL,

decode(bitand(t.property, 8388608), 8388608,

'SYS$SESSION', 'SYS$TRANSACTION')),

decode(bitand(t.flags, 1024), 1024, 'ENABLED', 'DISABLED'),

decode(bitand(t.flags, 2097152), 2097152, 'YES', 'NO'),

decode(bitand(t.property, 1024), 0, null, cu.name),

decode(bitand(t.flags, 8388608), 8388608, 'ENABLED', 'DISABLED'),

decode(bitand(t.property, 32), 32, null,

decode(bitand(s.spare1, 2048), 2048, 'ENABLED', 'DISABLED'))

from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o,

sys.obj$ cx, sys.user$ cu

where o.owner# = u.user#

and o.obj# = t.obj#

and bitand(t.property, 1) = 0

and t.bobj# = co.obj# (+)

and t.ts# = ts.ts#

and t.file# = s.file# (+)

and t.block# = s.block# (+)

and t.ts# = s.ts# (+)

and t.dataobj# = cx.obj# (+)

and cx.owner# = cu.user# (+)

9i中MONITORING字段的值是表的属性:decode(bitand(t.flags, 2097152), 2097152, 'YES', 'NO')。

而10g中则不同:

SQL> SELECT TEXT FROM DBA_VIEWS WHERE VIEW_NAME = 'DBA_TABLES';

TEXT

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

select u.name, o.name, decode(bitand(t.property,2151678048), 0, ts.name, null),

decode(bitand(t.property, 1024), 0, null, co.name),

decode((bitand(t.property, 512)+bitand(t.flags, 536870912)),

0, null, co.name),

decode(bitand(t.trigflag, 1073741824), 1073741824, 'UNUSABLE', 'VALID'),

decode(bitand(t.property, 32+64), 0, mod(t.pctfree$, 100), 64, 0, null),

decode(bitand(ts.flags, 32), 32, to_number(NULL),

decode(bitand(t.property, 32+64), 0, t.pctused$, 64, 0, null)),

decode(bitand(t.property, 32), 0, t.initrans, null),

decode(bitand(t.property, 32), 0, t.maxtrans, null),

s.iniexts * ts.blocksize,

decode(bitand(ts.flags, 3), 1, to_number(NULL),

s.extsize * ts.blocksize),

s.minexts, s.maxexts,

decode(bitand(ts.flags, 3), 1, to_number(NULL),

s.extpct),

decode(bitand(ts.flags, 32), 32, to_number(NULL),

decode(bitand(o.flags, 2), 2, 1, decode(s.lists, 0, 1, s.lists))),

decode(bitand(ts.flags, 32), 32, to_number(NULL),

decode(bitand(o.flags, 2), 2, 1, decode(s.groups, 0, 1, s.groups))),

decode(bitand(t.property, 32+64), 0,

decode(bitand(t.flags, 32), 0, 'YES', 'NO'), null),

decode(bitand(t.flags,1), 0, 'Y', 1, 'N', '?'),

t.rowcnt,

decode(bitand(t.property, 64), 0, t.blkcnt, null),

decode(bitand(t.property, 64), 0, t.empcnt, null),

t.avgspc, t.chncnt, t.avgrln, t.avgspc_flb,

decode(bitand(t.property, 64), 0, t.flbcnt, null),

lpad(decode(t.degree, 32767, 'DEFAULT', nvl(t.degree,1)),10),

lpad(decode(t.instances, 32767, 'DEFAULT', nvl(t.instances,1)),10),

lpad(decode(bitand(t.flags, 8), 8, 'Y', 'N'),5),

decode(bitand(t.flags, 6), 0, 'ENABLED', 'DISABLED'),

t.samplesize, t.analyzetime,

decode(bitand(t.property, 32), 32, 'YES', 'NO'),

decode(bitand(t.property, 64), 64, 'IOT',

decode(bitand(t.property, 512), 512, 'IOT_OVERFLOW',

decode(bitand(t.flags, 536870912), 536870912, 'IOT_MAPPING', null

))),

decode(bitand(o.flags, 2), 0, 'N', 2, 'Y', 'N'),

decode(bitand(o.flags, 16), 0, 'N', 16, 'Y', 'N'),

decode(bitand(t.property, 8192), 8192, 'YES',

decode(bitand(t.property, 1), 0, 'NO', 'YES')),

decode(bitand(o.flags, 2), 2, 'DEFAULT',

decode(s.cachehint, 0, 'DEFAULT', 1, 'KEEP', 2, 'RECYCLE', NULL)),

decode(bitand(t.flags, 131072), 131072, 'ENABLED', 'DISABLED'),

decode(bitand(t.flags, 512), 0, 'NO', 'YES'),

decode(bitand(t.flags, 256), 0, 'NO', 'YES'),

decode(bitand(o.flags, 2), 0, NULL,

decode(bitand(t.property, 8388608), 8388608,

'SYS$SESSION', 'SYS$TRANSACTION')),

decode(bitand(t.flags, 1024), 1024, 'ENABLED', 'DISABLED'),

decode(bitand(o.flags, 2), 2, 'NO',

decode(bitand(t.property, 2147483648), 2147483648, 'NO',

decode(ksppcv.ksppstvl, 'TRUE', 'YES', 'NO'))),

decode(bitand(t.property, 1024), 0, null, cu.name),

decode(bitand(t.flags, 8388608), 8388608, 'ENABLED', 'DISABLED'),

decode(bitand(t.property, 32), 32, null,

decode(bitand(s.spare1, 2048), 2048, 'ENABLED', 'DISABLED')),

decode(bitand(o.flags, 128), 128, 'YES', 'NO')

from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o,

sys.obj$ cx, sys.user$ cu, x$ksppcv ksppcv, x$ksppi ksppi

where o.owner# = u.user#

and o.obj# = t.obj#

and bitand(t.property, 1) = 0

and bitand(o.flags, 128) = 0

and t.bobj# = co.obj# (+)

and t.ts# = ts.ts#

and t.file# = s.file# (+)

and t.block# = s.block# (+)

and t.ts# = s.ts# (+)

and t.dataobj# = cx.obj# (+)

and cx.owner# = cu.user# (+)

and ksppi.indx = ksppcv.indx

and ksppi.ksppinm = '_dml_monitoring_enabled'

在这个表达式中:

decode(bitand(o.flags, 2), 2, 'NO',

decode(bitand(t.property, 2147483648), 2147483648, 'NO',

decode(ksppcv.ksppstvl, 'TRUE', 'YES', 'NO')))

首先判断这个表是否是临时表,然后判断是否这个表是否是外部表。对于临时表和外部表,设置MONITORING没有意义,因此表对应的值也是NO。如果不属于上面两种情况,则表中字段的值有初始化参数的值确定:

and ksppi.ksppinm = '_dml_monitoring_enabled'

所以10g中所有的普通表都是MONITORING为YES。是否是表本身上的属性是NOMONITORING,但是显示的结果是MONITORING导致了这个问题呢。

但是检查DBA_TAB_MODIFICATIONS视图发现了视图记录了这个表的修改,而这些修改的记录是依靠MONITORING属性的:

SQL> SELECT TABLE_NAME, PARTITION_NAME, INSERTS, UPDATES, DELETES, TIMESTAMP

2 FROM USER_TAB_MODIFICATIONS

3 WHERE TABLE_NAME = 'ORD_ORDER';

TABLE_NAME PARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP

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

ORD_ORDER 2735139 10791966 491 2007-05-03 22:00:02

ORD_ORDER ORD0304 437 0 0 2007-05-03 22:00:02

ORD_ORDER ORD0307 380 0 0 2007-05-03 22:00:02

ORD_ORDER ORD0310 190 0 0 2007-05-03 22:00:02

ORD_ORDER ORD0401 1092 29 0 2007-05-03 22:00:02

ORD_ORDER ORD0404 28138 27 0 2007-05-03 22:00:02

ORD_ORDER ORD0407 41737 104 0 2007-05-03 22:00:02

ORD_ORDER ORD0410 55830 482 0 2007-05-03 22:00:02

ORD_ORDER ORD0501 56141 444 0 2007-05-03 22:00:02

ORD_ORDER ORD0504 54723 546 0 2007-05-03 22:00:02

ORD_ORDER ORD0507 77262 1000 0 2007-05-03 22:00:02

ORD_ORDER ORD0510 191954 2090 0 2007-05-03 22:00:02

ORD_ORDER ORD0601 107024 1724 0 2007-05-03 22:00:02

ORD_ORDER ORD0604 118910 1341 0 2007-05-03 22:00:02

ORD_ORDER ORD0607 129039 2431 0 2007-05-03 22:00:02

ORD_ORDER ORD0610 122062 5496 0 2007-05-03 22:00:02

ORD_ORDER ORD0701 119021 16262 0 2007-05-03 22:00:02

ORD_ORDER ORD0704 137767 686953 35 2007-05-03 22:00:02

ORD_ORDER ORD0707 149083 1138992 60 2007-07-01 22:00:01

ORD_ORDER ORD0710 157907 1177425 55 2007-10-01 22:00:02

ORD_ORDER ORD0801 155147 1052681 45 2008-01-01 22:00:03

ORD_ORDER ORD0804 175290 1187081 29 2008-04-01 22:00:02

ORD_ORDER ORD0807 187778 1271790 32 2008-07-01 22:00:02

ORD_ORDER ORD0810 194450 1298860 57 2008-10-01 22:00:03

ORD_ORDER ORD0901 176321 1170333 54 2009-01-01 22:00:02

ORD_ORDER ORD0904 204774 1279347 70 2009-04-01 22:00:04

ORD_ORDER ORD0907 92682 496528 54 2009-07-01 22:00:02

已选择27行。

Oracle记录了每个分区的修改以及表的总修改记录数。这个信息应该在统计信息收集后被清除,由于统计信息一直没有收集,因此这个信息已经积累了很长时间。

问题看来和MONITORING没有关系,还要进一步检查导致问题的原因。

oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息