Oracle session分析

session

set linesize 300 pages 999             
col sid format 99999                   
col s# format 99999                    
col username format a10                
col spid for a10                       
col event format a36                   
col machine format a20                 
col program for a40                    
col p123 format a20                    
col wt format 999                      
col SQL_ID for a18                     
alter session set cursor_sharing=force;
SELECT /* XJ LEADING(S) FIRST_ROWS */ S.SID, 
    S.SERIAL# S#, 
    P.SPID, 
    S.MACHINE, 
    S.program, 
    S.EVENT, 
    S.P1 || '/' || S.P2 || '/' || S.P3 P123, 
    S.WAIT_TIME WT, 
    NVL(SQL_ID, S.PREV_SQL_ID) SQL_ID, 
    NVL(S.USERNAME, SUBSTR(P.PROGRAM, LENGTH(P.PROGRAM) - 6)) USERNAME 
FROM V$PROCESS P, V$SESSION S 
WHERE P.ADDR = S.PADDR 
AND S.STATUS = 'ACTIVE' 
AND P.BACKGROUND IS NULL; 


set linesize 200 pagesize 900
col message for a80
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select START_TIME,LAST_UPDATE_TIME, TIME_REMAINING, ELAPSED_SECONDS,sofar,totalwork, message from v$session_longops  where sid=&sid and SERIAL#=&siral and sofar<>totalwork order by LAST_UPDATE_TIME;   


cpu占比: 

set linesize 200
col username for a10
col event for a35
col program for a20 truncate
col cpu_p for 99.99
col  SQL_ID for a25
select ta.*,round(ta.cpu_time/tb.total_cpu * 100,1) cpu_usage from
(select s.username,s.program,s.event,s.sql_id,sum(trunc(m.CPU)) CPU_TIME,count(*) sum
        --,sum(m.PHYSICAL_READS) P_READ,sum(LOGICAL_READS) L_READ,
  from v$sessmetric m ,v$session s
where ( m.PHYSICAL_READS >100
       or m.CPU>100
       or m.LOGICAL_READS >100)
       and m.SESSION_ID = s.SID
       and m.SESSION_SERIAL_NUM = s.SERIAL#
       and s.status = 'ACTIVE'
       and username is not null
group by s.username,s.program,s.event,s.sql_id
order by 5 desc) ta,(select sum(cpu) total_cpu from v$sessmetric) tb
where rownum < 30;
 


查看连接:

set linesize 200 pagesize 900
col machine for a55
col username for a15
col module for a50
select inst_id, machine, status, count(1) from gv$session group by inst_id,machine,status;
col machine for a30
select inst_id, status, machine, username, module, count(*) from gv$session group by inst_id,status,machine,username,module order by 1,2,3,4;
select inst_id, machine, status, count(1) from gv$session group by inst_id,machine,status order by 1,4,3,2;
select username, count(*) from gv$session group by username;
set linesize 300
select * from v$resource_limit where RESOURCE_NAME in ('processes','sessions') order by 1;
select distinct username from v$session;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值