签到成功

知道了

CNDBA社区CNDBA社区

DB2常用监控性能SQL

2022-04-05 08:23 1489 0 原创 DB2
作者: hbhe0316

1.Get the TOP 10 SQLS by the Total Execution time

db2 "SELECT substr(stmt_text,1,100) as sql_statement, total_exec_time, total_sys_cpu_time, total_usr_cpu_time,num_executions, num_compilations FROM sysibmadm.snapdyn_sql ORDER BY total_exec_time desc FETCH FIRST 10 ROWS ONLY"

2.Get the Top 10 SQLS by Average Execution Timehttp://www.cndba.cn/hbhe0316/article/107906

db2 "SELECT substr(stmt_text,1,100) as sql_statement, total_exec_time, num_executions,DECIMAL((real(total_exec_time) / real(num_executions)),18,9) as avg_exec_time FROM sysibmadm.snapdyn_sql WHERE num_executions > 0 ORDER BY 4 desc FETCH FIRST 10 ROWS ONLY"

3.Get the Top 10 SQLS by Average CPU Time

db2 "SELECT substr(stmt_text,1,100) as sql_statement, total_sys_cpu_time, total_usr_cpu_time, num_executions,DECIMAL(((real(total_sys_cpu_time) + real(total_usr_cpu_time)) / real(num_executions)),18,9) as avg_cpu_time FROM sysibmadm.snapdyn_sql WHERE num_executions > 0 ORDER BY avg_cpu_time desc FETCH FIRST 10 ROWS ONLY"

4.Top 10 Ranking SQL by Number of Executionhttp://www.cndba.cn/hbhe0316/article/107906

db2 "SELECT substr(stmt_text,1,100) as sql_statement, total_exec_time, num_executions, stmt_sorts,num_compilations, DECIMAL((real(total_exec_time) / real(num_executions)),18,9) as avg_exec_time FROM sysibmadm.snapdyn_sql WHERE num_executions > 0 ORDER BY 3 desc FETCH FIRST 10 ROWS ONLY"

5.Top 10 Ranking SQL by Number of sorts

http://www.cndba.cn/hbhe0316/article/107906
http://www.cndba.cn/hbhe0316/article/107906

db2 "SELECT substr(stmt_text,1,100) as sql_statement, total_exec_time, num_executions, stmt_sorts,num_compilations, DECIMAL((real(total_exec_time) / real(num_executions)),18,9) as avg_exec_time FROM sysibmadm.snapdyn_sql WHERE num_executions > 0 ORDER BY stmt_sorts desc FETCH FIRST 10 ROWS ONLY"

6.TOP 10 SQLS BY IO

http://www.cndba.cn/hbhe0316/article/107906

db2 "select substr(stmt_text,1,100) as sql_statement, stmt_exec_time, num_executions,(pool_read_time + pool_write_time+direct_read_time + direct_write_time) as io_time from table(mon_get_pkg_cache_stmt(null,null,null,-2)) as t order by io_time desc fetch first 10 rows only"

7.监控视图APPLICATIONS ,检索应用连接显示执行状态、时长及SQLhttp://www.cndba.cn/hbhe0316/article/107906http://www.cndba.cn/hbhe0316/article/107906

db2 "select substr(STMT_TEXT,1,50) as sql_statement,APPLICATION_HANDLE, substr(APPLICATION_NAME,1,10) as APPLICATION_NAME,ELAPSED_TIME_SEC, ACTIVITY_STATE, QUERY_COST_ESTIMATE from sysibmadm.mon_current_sql order by ELAPSED_TIME_SEC fetch first 10 rows only"

8.监控视图APPLICATIONS ,检索应用连接的状态、地址等信息http://www.cndba.cn/hbhe0316/article/107906http://www.cndba.cn/hbhe0316/article/107906http://www.cndba.cn/hbhe0316/article/107906

db2 "select substr(A.AUTHID,1,10) as AUTH_ID, substr(A.APPL_NAME,1,20) as app_name, A.AGENT_ID as APP_HANDLE, substr(A.APPL_ID,1,25) as APPLICATION_ID, substr(A.APPL_STATUS,1,15) as status, A.STATUS_CHANGE_TIME, second(current timestamp-A.STATUS_CHANGE_TIME) as SEC_IN_STATUS, substr(A.CLIENT_NNAME,1,15) as CLIENT_NNAME from SYSIBMADM.APPLICATIONS A with ur"

版权声明:本文为博主原创文章,未经博主允许不得转载。

DB2

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1039608次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ