zoukankan      html  css  js  c++  java
  • 根据不同的指标获取TOP 10 SQL

    select sql.*,
           (select SQL_TEXT
              from dba_hist_sqltext t
             where t.sql_id = sql.sql_id
               and rownum = 1) SQLTEXT
      from (select a.*,
                   RANK() over(order by els desc) as r_els,
                   RANK() over(order by phy desc) as r_phy,
                   RANK() over(order by get desc) as r_get,
                   RANK() over(order by exe desc) as r_exe,
                   RANK() over(order by CPU desc) as r_cpu
              from (
                    select sql_id,
                            sum(executions_delta) exe,
                            round(sum(elapsed_time_delta) / 1e6, 2) els,
                            round(sum(cpu_time_delta) / 1e6, 2) cpu,
                            round(sum(iowait_delta) / 1e6, 2) iow,
                            sum(buffer_gets_delta) get,
                            sum(disk_reads_delta) phy,
                            sum(rows_processed_delta) RWO,
                            round(sum(elapsed_time_delta) /
                                  greatest(sum(executions_delta), 1) / 1e6,
                                  4) elsp,
                            round(sum(cpu_time_delta) /
                                  greatest(sum(executions_delta), 1) / 1e6,
                                  4) cpup,
                            round(sum(iowait_delta) /
                                  greatest(sum(executions_delta), 1) / 1e6,
                                  4) iowp,
                            round(sum(buffer_gets_delta) /
                                  greatest(sum(executions_delta), 1),
                                  2) getp,
                            round(sum(disk_reads_delta) /
                                  greatest(sum(executions_delta), 1),
                                  2) phyp,
                            round(sum(rows_processed_delta) /
                                  greatest(sum(executions_delta), 1),
                                  2) ROWP
                      from dba_hist_sqlstat s
                    --where snap_id between ... and ...
                     group by sql_id) a
            ) SQL
     where r_els <= 10
        or r_phy <= 10
        or r_cpu <= 10
     order by els desc

  • 相关阅读:
    解决方案:ubuntu无法获得锁,无法管理目录
    ACM经典题目——校门外的树
    【动态规划】01背包问题(通俗易懂,超基础讲解)
    从编程实现角度学习 Faster R-CNN(附极简实现)
    git clone 时,出现‘fatal: HTTP request failed‘
    git clone出现 fatal: unable to access 'https://github.com/...'的解决办法(亲测有效)
    Qt类库的模块
    java 中的 池
    sql 语句
    httpClient 发送http请求
  • 原文地址:https://www.cnblogs.com/ss-33/p/9076984.html
Copyright © 2011-2022 走看看