1,检测回滚段的争用
select sum(gets),sum(waits),sum(waits)/sum(gets) from v$rollstat;
SUM(waits)值应小于SUM(gets)值的1%
回卷段的竟争会降低系统的性能。
GETS代表回卷段被访问的次数
WAITS代表进程等待回卷段中哪个进程的次数
如果GETS与WAITS的比大于2%表示存在竟争问题
select rn.name,rs.gets 被访问次数,rs.waits 等待回退段块的次数,(rs.waits/rs.gets)*100 命中率 from v$rollstat rs,v$rollname rn
2,监控表空间的 I/O 比例
select df.tablespace_name name,df.file_name "file",f.phyrds pyr,f.phyblkrd pbr,f.phywrts pyw, f.phyblkwrt pbw
from v$filestat f, dba_data_files df where f.file# = df.file_id order by df.tablespace_name;
--监控表空间的 I/O读总数
select sum(f.phyrds) pyr from v$filestat f, dba_data_files df where f.file# = df.file_id;
--监控表空间的 I/O块读总数
select sum(f.phyblkrd) pbr from v$filestat f, dba_data_files df where f.file# = df.file_id;
--监控表空间的 I/O写总数
select sum(f.phywrts) pyw from v$filestat f, dba_data_files df where f.file# = df.file_id;
--监控表空间的 I/O块写总数
select sum(f.phyblkwrt) pbw from v$filestat f, dba_data_files df where f.file# = df.file_id;
物理读数量(V$filestat.phyrds)
物理写数量(V$filestat.phywrites)
PHYRDS : Number of physical reads done
PHYBLKRD: Number of physical blocks read
3,监控文件系统的 I/O 比例
select substr(a.file#,1,2) "#", substr(a.name,1,30) "Name", a.status, a.bytes, b.phyrds, b.phywrts
from v$datafile a, v$filestat b where a.file# = b.file#;
=========================================================
为了加深理解,简单的做了个测试
代码:--------------------------------------------------------------------------------
SQL> create table toms (str varchar2(64));
表已创建。
SQL> insert into toms values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from toms;
STR
----------------------------------------------------------------
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SQL> insert into toms select * from toms;
已创建 1 行。
SQL> /
已创建2行。
SQL> /
已创建4行。
SQL> /
已创建8行。
SQL> /
已创建16行。
SQL> /
已创建32行。
SQL> /
.......
SQL> /
已创建8192行。
SQL> commit;
提交完成。
SQL> select count(*) from toms;
COUNT(*)
----------
16384
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 89201304 bytes
Fixed Size 453272 bytes
Variable Size 67108864 bytes
Database Buffers 20971520 bytes
Redo Buffers 667648 bytes
数据库装载完毕。
数据库已经打开。
SQL> alter system set db_file_multiblock_read_count=16;
SQL> select phyrds,phyblkrd from v$filestat where file#=8;
PHYRDS PHYBLKRD
---------- ----------
4 4
SQL> select count(*) from toms;
COUNT(*)
----------
16384
SQL>
SQL> select phyrds,phyblkrd from v$filestat where file#=8;
PHYRDS PHYBLKRD
---------- ----------
17 191
SQL> select 17-4,191-4 from dual;
17-4 191-4
---------- ----------
13 187
SQL> select 187/13 from dual;
187/13
----------
14.3846153
SQL>
SQL> select phyrds,phyblkrd from v$filestat where file#=8;
PHYRDS PHYBLKRD
---------- ----------
17 191
SQL> alter system set db_file_multiblock_read_count=64;
系统已更改。
SQL> select count(*) from toms;
COUNT(*)
----------
16384
SQL>
SQL> select phyrds,phyblkrd from v$filestat where file#=8;
PHYRDS PHYBLKRD
---------- ----------
20 377
SQL> select phyrds,phyblkrd from v$filestat where file#=8;
PHYRDS PHYBLKRD
---------- ----------
20 377
SQL> select (377-191)/3 from dual;
(377-191)/3
-----------
62
SQL> alter system set db_file_multiblock_read_count=128;
系统已更改。
SQL> select count(*) from toms;
COUNT(*)
----------
16384
SQL> select phyrds,phyblkrd from v$filestat where file#=8;
PHYRDS PHYBLKRD
---------- ----------
22 561
SQL> select (561-377)/2 from dual;
(561-377)/2
-----------
92
SQL>