【DB2】监控动态SQL语句
一、db2监控动态SQL(快照监控)
db2示例用户登陆后,使用脚本语句db2 get snapshot for all on dbname>snap.out
也可以使用db2 get snapshot for dynamic SQL on dbname>snap.out,此语句是只记录上一语句中的部分
Tips:如果需要监控尽可能多的SQL语句,建议增加DBM配置参数
以下是动态SQL快照
Dynamic SQL Snapshot Result Database name = QINDB Database path = /db2home/db2inst1/db2inst1/NODE0000/SQL00002/
Number of executions = 3 --编译次数,为累加值
Number of compilations = 1 --SQL语句编译的最长时间
Worst preparation time (ms) = 87
Best preparation time (ms) = 87
Internal rows deleted = Not Collected
Internal rows inserted = Not Collected
Rows read = Not Collected
Internal rows updated = Not Collected
Rows written = Not Collected
Statement sorts = Not Collected
Statement sort overflows = Not Collected
Total sort time = Not Collected
Buffer pool data logical reads = Not Collected
Buffer pool data physical reads = Not Collected
Buffer pool temporary data logical reads = Not Collected
Buffer pool temporary data physical reads = Not Collected
Buffer pool index logical reads = Not Collected
Buffer pool index physical reads = Not Collected
Buffer pool temporary index logical reads = Not Collected
Buffer pool temporary index physical reads = Not Collected
Buffer pool xda logical reads = Not Collected
Buffer pool xda physical reads = Not Collected
Buffer pool temporary xda logical reads = Not Collected
Buffer pool temporary xda physical reads = Not Collected
Total execution time (sec.microsec)= Not Collected --SQL语句的总执行时间
Total user cpu time (sec.microsec) = Not Collected
Total system cpu time (sec.microsec)= Not Collected
Total statistic fabrication time (milliseconds) = Not Collected
Total synchronous runstats time (milliseconds) = Not Collected
Statement text = select * from len.cust_info where cust_id like '%09' --SQL语句文本
Number of executetions:可以帮助找到最优的那些重要语句,它对于帮助计算语句的平均执行时间也很有用。
Rows read :可以帮助识别读取行数最多的动态SQL语句,如果读取行数最多,通常意味着进行全表扫描。
Total execution time:是将语句每次执行时间加起来得到的总时间,我们可以利用该时间除以Number of executrtions,可以得到平均执行时间。如果语句的平均执行时间很长,可能是因为表扫描或者出现锁等待。
基于上述使用语句db2 get snapshot for all on dbname生成的文本内容,我们可以使用grep对快照的输出内容执行搜索
例如:
<1> 识别是否存在死锁
grep -n "Deadlocks detected" snap.out |grep -v "= 0" |more
<2> 搜索执行最频繁的SQL语句
grep -n "Number of executions" snap.out | grep -v "= 0" | sort -k 6rn |more
<3> 查询总的执行时间
grep -n "Total execution time" snap.out | grep -v "= 0.0"| sort -k 6nr| more
二、监控动态SQL(db2top)
使用db2top命令找出最频繁、最耗时的SQL(使用db2数据库用户登录)
db2top –d dbname
按D,进入到SQL监控界面(如果没开大写,可以使用shift+d)
按z,倒序排序
输入排序列的序号,从0开始
按L,输入SQL的序列号,查看SQL明细
以下为示例操作:
(1)db2inst1@Linux:/qinys> db2top -d qindb

(2)按D进入

(3)按z倒序排序,此处我输入3,表示按照执行时间排序

(4)按L输入SQL序列号,查看SQL详细


从上图我们就可以查看SQL详细了
【DB2】监控动态SQL语句的更多相关文章
- Ibatis.Net 动态SQL语句学习(六)
在学习动态SQL语句之前,首先必须对条件查询有一定了解,先来学习如何向IBatis.Net的映射文件里传入参数吧. 一.条件查询 1.传递单个参数 如根据Id查询: <select id=&qu ...
- 动态sql语句、逆向工程(generator)、分页助手(pagehelper)
1.动态sql语句 if if where 配合使用 <select id="selectByWhere" resultType="com.alibaba.wlq. ...
- MySQL存储过程动态SQL语句的生成
用Mysql存储过程来完成动态SQL语句,使用存储过程有很好的执行效率: 现在有要求如下:根据输入的年份.国家.节假日类型查询一个节假日,我们可以使用一般的SQL语句嵌入到Java代码中,但是执行效率 ...
- 动态sql语句基本语法--Exec与Exec sp_executesql 的区别
http://www.cnblogs.com/goody9807/archive/2010/10/19/1855697.html 动态sql语句基本语法 1 :普通SQL语句可以用Exec执行 ...
- mybatis实战教程(mybatis in action)之八:mybatis 动态sql语句
mybatis 的动态sql语句是基于OGNL表达式的.可以方便的在 sql 语句中实现某些逻辑. 总体说来mybatis 动态SQL 语句主要有以下几类:1. if 语句 (简单的条件判断)2. c ...
- MyBatis学习(三)、动态SQL语句
三.动态SQL语句 有些时候,sql语句where条件中,需要一些安全判断,例如按某一条件查询时如果传入的参数是空,此时查询出的结果很可能是空的,也许我们需要参数为空时,是查出全部的信息.使用Orac ...
- 三、动态SQL语句
//备注:该博客引自:http://limingnihao.iteye.com/blog/106076 有些时候,sql语句where条件中,需要一些安全判断,例如按某一条件查询时如果传入的参数是空, ...
- IBatis.net动态SQL语句
在学习动态SQL语句之前,首先必须对条件查询有一定了解,先来学习如何向IBatis.Net的映射文件里传入参数. 一.条件查询 1.传递单个参数 如根据Id查询: <select id=&quo ...
- 存储过程中执行动态Sql语句
MSSQL为我们提供了两种动态执行SQL语句的命令,分别是EXEC和sp_executesql;通常,sp_executesql则更具有优势,它提供了输入输出接口,而EXEC没有.还有一个最大的好处就 ...
随机推荐
- JAVA之带转义字符的json字符串解析
Json数据: { "ret": "0", "Weathers": "[{\"date\":\"20 ...
- [转]nginx下的url rewrite
转:http://zhengdl126.iteye.com/blog/698206 if (!-e $request_filename){rewrite "^/index\.html&quo ...
- No identifier specified for entity: springboot-jpa报错No identifier specified for entity
说明:此次学习使用了springboot框架,jpa注解映射实体类 1,No identifier specified for entity: com.tf.model.User 看到此错误第一反应百 ...
- JavaScript:Events
ylbtech-JavaScript:Events 1.返回顶部 JavaScript 事件参考手册 事件通常与函数配合使用,这样就可以通过发生的事件来驱动函数执行. 事件句柄 HTML 4.0 的新 ...
- Qt解决:Qobject::connect queue arguments of type ‘xxxx’,Make sure ‘xxxx’ is registered using qRegister
解决方法:在调用connect之前,通过 qRegisterMetaType() 注册你connect函数里对象的类型代码如下: typedef QString CustomString;//你自己定 ...
- Palindrome Number leetcode java
题目: Determine whether an integer is a palindrome. Do this without extra space. click to show spoiler ...
- Java 读取 .properties 配置文件
java 开发中,经常要读取 properties 配置文件,下面介绍几种读取方式: 1.基于 InputStream 读取配置文件 该方式的优点在于可以读取任意路径下的配置文件 Properties ...
- 如何配置官方peerDroid,使其运行起来
一.Peer Droid是JXME协议到android平台的移植,开发者可以利用它来实现android设备以及传统PC机通讯的应用程序,peerDroid的官方demo主要是实现PC端peer和and ...
- 简单介绍Ceph分布式存储集群
在规划Ceph分布式存储集群环境的时候,对硬件的选择很重要,这关乎整个Ceph集群的性能,下面梳理到一些硬件的选择标准,可供参考: 1)CPU选择 Ceph metadata server会动态的重新 ...
- 将iPhone投影到Mac上
将iPhone投影到Mac上 有时候, 出于演示须要, 又或者嫌弃iPhone屏幕太小了, 我想把画面弄到mac上. 这时候, 就须要将iPhone投影到Mac上. 至于怎样做呢? 这就是本文要说明的 ...