• Oracle 性能监控sql


    陈高峰原创

    基本都是工作中常用,性能优化和管理必备的sql;

    --1.查看表锁
    select * from sys.v_$sqlarea where disk_reads>100;

    --2.监控事例的等待
    select event,sum(decode(wait_Time,0,0,1)) "Prev",
    sum(decode(wait_Time,0,1,0)) "Curr",count(*) "Tot"
    from v$session_Wait
    group by event order by 4;

    --3.性能最差的SQL
    SELECT * FROM ( SELECT PARSING_USER_ID EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,sql_text
                    FROM v$sqlarea
                    ORDER BY disk_reads DESC)
    WHERE ROWNUM<100;
                                
    --4.读磁盘数超100次的sql
    select * from sys.v_$sqlarea where disk_reads>100 ;

    --5.最频繁执行的sql
    select * from sys.v_$sqlarea where executions>100;

    --6.查询使用CPU多的用户session
    select a.sid,spid,status,substr(a.program,1,40) prog,a.terminal,osuser,value/60/100 value
    from v$session a,v$process b,v$sesstat c
    where c.statistic#=12 and
          c.sid=a.sid and
          a.paddr=b.addr
    order by value desc;

    --7.当前每个会话使用的对象数
    SELECT a.sid,s.terminal,s.program,count(a.sid)
    FROM V$ACCESS a,V$SESSION s
    WHERE a.owner <> 'SYS'AND s.sid = a.sid
    GROUP BY a.sid,s.terminal,s.program
    ORDER BY count(a.sid);

    --8.数据表占用空间大小情况
    select segment_name,tablespace_name,bytes,blocks
    from user_segments
    where segment_type='TABLE'
    ORDER BY bytes DESC ,blocks DESC;

  • 相关阅读:
    文字转语音功能
    windows定时计划任务
    写电子合同,爬过的坑,趟过的雷,犯过的错,都是泪
    前端应该如何去认识http
    I/O理解
    观察者模式
    js --代理模式
    js --策略模式
    js --单例模式
    js 单线程 异步
  • 原文地址:https://www.cnblogs.com/Golf9527/p/2564047.html
Copyright © 2020-2023  润新知