好学IT学院:IT信息技术分享交流平台
来源:赛迪网  作者:韩东  发布时间:2008-12-04  ★★★加入收藏〗〖手机版
摘要:【赛迪网-IT技术报道】性能相关内容1、捕捉运行很久的SQLcolumn username format a12 column opname format a16 column progress format a8 SELECT Usern……

【赛迪网-IT技术报道】性能相关内容

1、捕捉运行很久的SQL

column username format a12
column opname format a16
column progress format a8
SELECT Username, Sid, Opname,
Round(Sofar * 100 / Totalwork, 0)

'%' AS Progress, Time_Remaining,
Sql_Text
FROM V$session_Longops, V$sql
WHERE Time_Remaining <> 0
AND Sql_Address = Address
AND Sql_Hash_Value = Hash_Value;

2、求DISK READ较多的SQL

SELECT St.Sql_Text
FROM V$sql s, V$sqltext St
WHERE s.Address = St.Address
AND s.Hash_Value = St.Hash_Value
AND s.Disk_Reads > 300;

3、求DISK SORT严重的SQL

SELECT Sess.Username, SQL.Sql_Text, Sort1.Blocks
FROM V$session Sess, V$sqlarea SQL, V$sort_Usage Sort1
WHERE Sess.Serial# = Sort1.Session_Num
AND Sort1.Sqladdr = SQL.Address
AND Sort1.Sqlhash = SQL.Hash_Value
AND Sort1.Blocks > 200;

4、监控索引是否使用

alter index &index_name monitoring usage;
alter index &index_name nomonitoring usage;
select * from v$object_usage where index_name = &index_name;

5、求数据文件的I/O分布

SELECT Df.NAME, Phyrds, Phywrts, Phyblkrd, Phyblkwrt, Singleblkrds, Readtim,
Writetim
FROM V$filestat Fs, V$dbfile Df
WHERE Fs.File# = Df.File#
ORDER BY Df.NAME;

6、查看还没提交的事务

select * from v$locked_object;
select * from v$transaction;

7、回滚段查看

SELECT Rownum, Sys.Dba_Rollback_Segs.Segment_Name NAME,
V$rollstat.Extents Extents, V$rollstat.Rssize Size_In_Bytes,
V$rollstat.Xacts Xacts, V$rollstat.Gets Gets, V$rollstat.Waits Waits,
V$rollstat.Writes Writes, Sys.Dba_Rollback_Segs.Status Status
FROM V$rollstat, Sys.Dba_Rollback_Segs, V$rollname
WHERE V$rollname.NAME(+) = Sys.Dba_Rollback_Segs.Segment_Name
AND V$rollstat.Usn(+) = V$rollname.Usn
ORDER BY Rownum

8、查看系统请求情况

SELECT Decode(NAME, 'summed dirty write queue length', VALUE) /
Decode(NAME, 'write requests', VALUE) "Write Request Length"
FROM V$sysstat
WHERE NAME IN ('summed dirty queue length', 'write requests')
AND VALUE > 0;

Oracle数据库设计要做到五戒
  众所周知,数据库设计的好坏直接关系到数据库运行的效率。根据笔者的经验,对于提升数据库性能来说,合理的数据库设计,比升级服务器的硬件…
  • 好学触屏公众号虎力全开、杨帆起航!
  • 好学考试H5触屏版开放内测