最近检查数据库,发现库中有很多表存在着行链接的现象。
select * from user_tables u where u.chain_cnt > 0
analyze table ow_wf_processes list chained rows
select * from chained_rows
---行链接问题测试
--找到block_id
select dbms_rowid.rowid_block_number(rowid), rowid from ow_wf_processes;
--根据block_id去找对应的file_id
select * from dba_extents de
where 716231 >= de.block_id
and 716231 <= de.block_id + de.blocks
and de.tablespace_name = 'DVBCETUS'
and de.segment_name = upper('ow_wf_processes')
--将该block的信息输出到udmp下:
alter system dump datafile 46 block 716231
输出的内容:
*** 2008-03-22 22:22:24.130
*** SESSION ID:(19.28535) 2008-03-22 22:22:24.120
Start dump data blocks tsn: 9 file#: 46 minblk 716231 maxblk 716231
buffer tsn: 9 rdba: 0x0b8aedc7 (46/716231)
scn: 0x0000.00a9096c seq: 0x01 flg: 0x02 tail: 0x096c0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0b8aedc7
Object id on Block? Y
seg/obj: 0xbb24 csc: 0x00.a9096a itc: 1 flg: - typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 xid: 0x0004.020.000003f1 uba: 0x10417668.06db.18 --U- 7 fsc 0x0000.00a9096c
data_block_dump
===============
tsiz: 0xfb8
hsiz: 0x20
pbl: 0x101e5f4e4
bdba: 0x0b8aedc7
flag=-----------
ntab=1
nrow=7
frre=-1
fsbo=0x20
fseo=0x4b2
avsp=0x492
tosp=0x492
0xe:pti[0] nrow=7 offs=0
0x12:pri[0] offs=0x6f0
0x14:pri[1] offs=0x693
0x16:pri[2] offs=0x62a
0x18:pri[3] offs=0x5c7
0x1a:pri[4] offs=0x56a
0x1c:pri[5] offs=0x50b
0x1e:pri[6] offs=0x4b2
block_row_dump:
tab 0, row 0, @0x6f0
tl: 2248 fb: -----LP- lb: 0x1 cc: 1
col 0: [2242]
72 65 65 6e 3d 22 32 35 35 22 20 72 65 64 3d 22 32 35 35 22 2f 3e 0a 20 20
20 20 20 20 20 20 20 20 20 20 3c 66 6f 6e 74 3e 26 71 75 6f 74 3b 26 71 75
6f 74 3b 3c 2f 66 6f 6e 74 3e 0a 20 20 20 20 20 20 20 20 20 20 20 20 3c 73
....
tab 0, row 1, @0x693
tl: 93 fb: --H-F--- lb: 0x1 cc: 12
nrid: 0x0b8aedc4.0
col 0: [ 4] c3 02 02 35
col 1: [14] 6e 65 77 69 6e 73 74 61 6c 6c 20 39 5f 30
col 2: *NULL*
col 3: *NULL*
col 4: [ 6] 39 2e 30 20 20 20
col 5: [16] ba bc d6 dd ca fd d7 d6 b5 e7 ca d3 b9 ab cb be
col 6: [ 5] 61 64 6d 69 6e
col 7: [ 2] c1 0a
col 8: *NULL*
col 9: [ 7] 78 68 04 02 17 32 13
col 10: [11] 68 61 6e 67 7a 68 6f 75 64 76 62
col 11: [ 7] 78 68 03 0e 17 0a 1c
tab 0, row 2, @0x62a
tl: 105 fb: --H-F--- lb: 0x1 cc: 12
nrid: 0x0b8aedc8.0
col 0: [ 4] c3 06 58 2f
col 1: [15] 6e 65 77 69 6e 73 74 61 6c 6c 20 31 31 5f 30
col 2: *NULL*
col 3: *NULL*
col 4: [ 6] 31 31 2e 30 20 20
col 5: [16] ba bc d6 dd ca fd d7 d6 b5 e7 ca d3 b9 ab cb be
col 6: [ 5] 61 64 6d 69 6e
col 7: [ 2] c1 0a
col 8: [11] 68 61 6e 67 7a 68 6f 75 64 76 62
col 9: [ 7] 78 68 04 05 16 38 32
col 10: [11] 68 61 6e 67 7a 68 6f 75 64 76 62
col 11: [ 7] 78 68 04 02 17 32 13
tab 0, row 3, @0x5c7
tl: 99 fb: --H-F--- lb: 0x1 cc: 12
nrid: 0x0b8aedca.0
...
如何查看是哪些行存在着行链接:
select * from ow_wf_processes wp
where wp.rowid in(
select cr.head_rowid from chained_rows cr
where cr.table_name = 'OW_WF_PROCESSES')
备份这些行的数据:
create table bak_data_wf_proce as
select * from ow_wf_processes wp
where wp.rowid in(
select cr.head_rowid from chained_rows cr
where cr.table_name = 'OW_WF_PROCESSES')
删除这些数据:
delete from ow_wf_processes wp
where wp.rowid in(
select cr.head_rowid from chained_rows cr
where cr.table_name = 'OW_WF_PROCESSES')
修改pctfree参数:
alter table ow_wf_processes pctfree 25;
将这些数据插回到表中,并对表进行分析:
insert into ow_wf_processes
select * from bak_data_wf_proce;
....