- 最后登录
- 2014-8-26
- 在线时间
- 2 小时
- 威望
- 0
- 金钱
- 32
- 注册时间
- 2012-1-9
- 阅读权限
- 10
- 帖子
- 6
- 精华
- 0
- 积分
- 0
- UID
- 153
|
9#
发表于 2012-1-10 16:23:35
原帖由 maclean 于 2012-1-4 18:56 发表 分析(analyze or dbms_stats) 不可用 dbms_space也不可用 的情况下可以 通过rowid来大致定位select count(distinct dbms_rowid.rowid_block_number(rowid) || dbms_rowid.rowid_relative_fno(rowid)) ...
这种方法不行的,只要有delete,就很不准确了。
如果真的不能做表分析,那么你就dump segment header去看吧。
创建一个表,高水位下187个block
- SQL> create table t as select * from dba_objects;
- Table created.
- SQL> exec dbms_stats.gather_table_stats('KAMUS','T');
- PL/SQL procedure successfully completed.
- SQL> select table_name,num_rows,blocks from tabs where table_name='T';
- TABLE_NAME NUM_ROWS BLOCKS
- ------------------------------ ---------- ----------
- T 13333 187
复制代码
删掉大部分记录,只留1条,高水位不变。
- SQL> delete from t where rownum<13333;
- 13332 rows deleted.
- SQL> exec dbms_stats.gather_table_stats('KAMUS','T');
- PL/SQL procedure successfully completed.
- SQL> select table_name,num_rows,blocks from tabs where table_name='T';
- TABLE_NAME NUM_ROWS BLOCKS
- ------------------------------ ---------- ----------
- T 1 187
复制代码
如果用上面这个SQL,只能得出1个block,因为确实只有一个rowid了
- SQL> select count(distinct dbms_rowid.rowid_block_number(rowid) || dbms_rowid.rowid_relative_fno(rowid)) "reality block used" from t;
- reality block used
- ------------------
- 1
复制代码
找出segment header block,做dump
- SQL> select header_file,header_block,blocks,extents from dba_segments where segment_name='T' and owner='KAMUS';
- HEADER_FILE HEADER_BLOCK BLOCKS EXTENTS
- ----------- ------------ ---------- ----------
- 4 5610 256 17
- SQL> alter system dump datafile 4 block 5610;
- System altered.
- SQL> SELECT p.TRACEFILE
- FROM v$session s, v$process p, v$mystat m
- WHERE s.paddr = p.addr
- AND s.SID = m.SID
- AND m.statistic# = 0; 2 3 4 5
- TRACEFILE
- ------------------------------------------------------------------------------------------------------------------------
- /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_26987.trc
复制代码
然后看trc文件,其中会有类似如下显示
- --------------------------------------------------------
- Low HighWater Mark :
- Highwater:: 0x0100173b ext#: 16 blk#: 59 ext size: 128
- #blocks in seg. hdr's freelists: 0
- #blocks below: 187
- mapblk 0x00000000 offset: 16
- Level 1 BMB for High HWM block: 0x01001700
- Level 1 BMB for Low HWM block: 0x01001700
- --------------------------------------------------------
复制代码
注意其中的#blocks below: 187,这就跟表分析得出的结果是一样的。 |
|