Oracle之 db file sequential read等待事件优化思想(2)

3.1、 需要检查,通过合理执行partition能否减少FTS范围。例如为获得100万个数据中10万个数据而执行FTS时,将10万个数据相应的范围利用partition分开,则可以将FTS的范围缩小至1/10。

3.2、 查看表的行迁移、行链接、pctfree,如果行迁移数量过高,pctfree 过低,则增大pctfree ,重建表。如果行链接过高,则加大BLOCK块
-- 查看行迁移/行链接
SQL> analyze table emp list chained rows;
SQL> select count(*) from chained_rows where table_name='EMPLOYEES_TEMP';

行迁移加大表的 pctfree ,重建表。

行链接只有通过加大BLOCK块的方式才可以避免,如下:
create tablespace dba_16k
blocksize 16K
datafile '/home/oracle/dba_16k.DBF' size 100M
autoextend on
extent management local
segment space management auto;
alter table EMPLOYEES_TEMP move tablespace dba_16k;
alter index idx_emp_id rebuild ;
delete from chained_rows ;
commit;
analyze table EMPLOYEES_BK list chained rows into chained_rows;
select count(*) from chained_rows where table_name='EMPLOYEES_TEMP';


4、OS/裸设备层
如果利用sql的优化或高速缓存区的优化也不能解决问题,就应该怀疑I/O系统本身的性能。将db file scattered read事件的等待次数和等待时间比较后,如果平均等待时间长,缓慢的I/O系统成为原因的可能性高。之前也讨论过,I/O系统上的性能问题在多钟情况下均会发生,因此需要充分调查各种因素。
利用v$filestat视图,可分别获得各数据文件关于Multi Block I/O和Single Block I/O的活动信息。

select f.file#,
 f.name,
 s.phyrds,
 s.phyblkrd,
 s.readtim, --所有的读取工作信息
s.singleblkrds,
 s.singleblkrdtim, --Single Block I/O
 (s.phyblkrd - s.singleblkrds) as multiblkrd, --Multi Block I/O次数
(s.readtim - s.singleblkrdtim) as multiblkrdtim, --Multi Block I/O时间
round(s.singleblkrdtim /
 decode(s.singleblkrds, 0, 1, s.singleblkrds),
 3) as singleblk_avgtim, --Single Block I/O 平均等待时间(cs)
round((s.readtim - s.singleblkrdtim) /
 nullif((s.phyblkrd - s.singleblkrds), 0),
 3) as multiblk_avgtim --Multi Block I/O 平均等待时间(cs)
from v$filestat s, v$datafile f
 where s.file# = f.file#;

如果特点文件上平均执行时间表现的过高,则应该通过提高该文件所在的I/O系统的性能,以此改善性能。没有关于Multi Block I/O的最合理的平均等待时间值,但一般应该维持10微妙左右的平均等待时间。

说明:总结于网络

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12699c3d84b318a642add3e16e1b068a.html