oracle表碎片对性能影响,oracle 表碎片太多的处理办法

某张结果表在etl过程中频繁的被dml语句操作,导致整个表的碎片激增。原来7g多的空间经过一段时间的运行增长至80g。。。。。汗

通过move的方式来解决该办法,在网上搜罗了一些操作说明,供参考

一、碎片程度查看

在没有toad的情况下可以通过如下语句:

select tablespace_name,count(tablespace_name) from dba_free_space group by tablespace_name

having count(tablespace_name)>10;

alter tablespace name coalesce;

alter table name deallocate unused;

create or replace view ts_blocks_v as

select tablespace_name,block_id,bytes,blocks,'free space' segment_name from dba_free_space

union all

select tablespace_name,block_id,bytes,blocks,segment_name from dba_extents;

select * from ts_blocks_v;

select tablespace_name,sum(bytes),max(bytes),count(block_id) from dba_free_space

group by tablespace_name;

二、查看碎片程度高的表

SELECT segment_name table_name , COUNT(*) extents

FROM dba_segments WHERE owner NOT IN ('SYS', 'SYSTEM') GROUP BY segment_name

HAVING COUNT(*) = (SELECT MAX( COUNT(*) ) FROM dba_segments GROUP BY segment_name);

三、解决方法

If you have to rebuild a table,always consider the 'move' command first.Availability can be reduced,but the benefit to administrative safty and convenience is large.There are no windows of opportunity for data to go missing.----Jonathan Lewis.

如果必须要重建表,alter table ...move tablespace...绝对是第一选择,理由如下:

1 对于大表move时,对此表的查询不受影响,只有在move操作完成的瞬间受影响。DML操作受影响。

2 index结构不受影响,只需move完成后rebuild。

3 与其它对象依赖关系不受影响,操作前不必为对象间的依赖关系操心。

4 move操作可以parallel。

5 NOLOGGING选项对move操作有作用,可大大加快重建速度。如果要move的表是nologging的,则不需指定。

基于以上理由,move是rebuild table的最佳选择,应该优先考虑,大家可以对照以上优点考虑一下用exp/imp的优缺点。采取的策略根据实际需求的不同而不同

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/223653/viewspace-1254582/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值