oracle中优化io,Oracle优化之I/O解析(三)

3、oracle中IO问题及其解决思路

总等待时间=34420(TOP 5事件中的Waits)*100%/53.34%(TOP5Event中waits占的比例)=645294s

总响应时间=总等待时间+CPU工作时间(CPU used by this session中Total)=17782162s

CPU工作时间的比例=cpu工作时间/总响应时间=96.4%

等待事件中"db file sequential read"的比例=这个等待事件占用的时间/总响应时间=1.9%

查看比例看是否是IO事件所引起的等待时间。

我们在做系统优化之前先分析系统是CPU负载系统还是IO负载系统对于我们的优化方向和最终的优化效果起很大的作用。

等待事件分类:

与数据文件相关的IO事件:

"db file sequential read"

"db file scattered read"

"db file parallel read"

"direct path read"

"direct path write"

"direct path read(lob)"

"direct path write(lob)"

与控制文件相关的IO事件:

"contol file parallel write"

"control file sequential read"

"control file single write"

与Redo日志相关的IO事件:

"log file parallel write"

"log file sync"

"log file sequential read"

"log file single write"

"switch logfile command"

"log file switch completion"

"log file swtich(clearing log file)"

"log file switch(checkpoint incomplete)"

"log switch/archive"

"log file switch (archiving needed)"

与Buffer cache相关的IO事件:

"db file parallel write"

"db file single write"

"write complete waits"

"free buffer waits"

判断一个索引是否需要重建?

对一个索引进行结构分析后,如果该索引占用超过一个数据块,且满足以下条件之一:

B-tree树的高度大于3;使用百分比低于75%;数据删除率大于15%:

analyze  index index_name compute statistics;

analyze index index_name validate structure;

select btree_space,--if >8192(块的大小)

height,--if >3

pct_used,--if<75

del_lf_rows/(decode(lf_rows,0,1,lf_rows)) *100 as deleted_pct --if>20%

from index_stats;

通过视图V$SQL_PLAN来查找系统中存在FULL Table Scan和Fast Full Index Scan的SQL语句:

查找Full Table Scan的语句:

select sql_text from v$sqlarea t,v$sql_plan p

where t.hash_value=p.hash_value and p.operation='TABLE ACCESS'

and p.options='FULL';

查找Fast Full Index Scan的语句:

select sql_text from v$sqlarea t,v$sql_plan p

where t.hash_value=p.hash_value and p.operation='INDEX'

and p.options='FULL SCAN';

FULL  TABLE SCAN 通常是由于以下几个原因引起的:

1)条件字段上没有索引

2)CBO中,对象的统计数据不正确

3)CBO中,SQL语句中引用到了无法估算统计数据的对象

4)优化器认为索引扫描代价过高

在Oracle中存在一个参数optimizer_index_cost_adj,该参数的值代表一个百分数,

如果对索引扫描的代价达到或者超过全表扫描的代价的这个百分比值时,优化器就采用全表扫描

optimizer_index_cost_adj 是一个全局性的参数,它的合理值是通过长期调整胡来的。一般来说是一个介于1到100之间的数字。

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值