首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Oracle 快速性能确诊工具ASH

2012-09-29 
Oracle 快速性能诊断工具ASH在Oracle 10g的性能调优时,可以使用到的工具主要有三个,分别为ASH(active sess

Oracle 快速性能诊断工具ASH

在Oracle 10g的性能调优时,可以使用到的工具主要有三个,分别为ASH(active session history)、AWR(automaticworkload repository)和ADDM(automatic database diagnosticmonitor)。这些工具比9i中的statspack有很大提升。

试想,在数据库出现性能问题,慢得要死的时候,最需要知道的就是系统慢在哪里。知道得越快越好。如果等待某个取样时间到了之后才能分析,这不是一个令人满意的解决过程。以前遇到这种情况,我们会去手工查动态性能视图,但在10g中,使用ASH就可以快速定位问题。

?

ASH工具主要查询的是v$active_session_history视图,根据这个视图我们可以延伸出很多功能。

?

(miki西游 @mikixiyou 原文http://mikixiyou.iteye.com/blog/1630056)

?

--------------------------------------------- 最近5分钟消耗CPU Top 10-------------------------------------------SQL> select * from(select session_id, session_serial#, count(*)from v$active_session_historywhere session_state= 'ON CPU' and sample_time > sysdate - interval '5' minutegroup by session_id, session_serial#order by count(*) desc)where rownum <= 10;------------------------------------------------ 最近5分活动会话Top 10----------------------------------------------SQL> select * from(select session_id, session_serial#,count(*)from v$active_session_historywhere session_state='WAITING'? and sample_time >? sysdate - interval '5' minutegroup by session_id, session_serial#order by count(*) desc)where rownum <= 10;

?

这两个查询可以查询出数据库实例中最近5分钟的活动会话,但这些是什么应用的连接和他们执行什么SQL,需要进一步分析。

?

?

------------------------ Who is that SID?----------------------set lines 200col username for a10col osuser for a10col machine for a10col program for a10col resource_consumer_group for a10col client_info for a10SQL> select? serial#, username, osuser, machine, program, resource_consumer_group, client_infofrom v$session where sid=&sid;----------------------------- What did that SID do?---------------------------SQL> select distinct sql_id, session_serial# from v$active_session_historywhere sample_time >? sysdate - interval '5' minuteand session_id=&sid;-------------------------------------------------- Retrieve the SQL from the Library Cache:------------------------------------------------col sql_text for a80SQL> select sql_text from v$sql where sql_id='&sqlid';

?

通过ASH,可以快速定位数据库实例的活动情况。

?

热点排行