db2查找执行次数最多的sql

用此方法同时能够得到cost最大的语句


--首先抓取snapshot
[db2inst2@localhost ~]$ db2 get snapshot for all on sample > snap.out

--根据执行次数排序
[db2inst2@localhost ~]$ grep -ni "number of executions" snap.out |grep -v "=0" |sort -k 6,6rn
846: Number of executions = 306
1198: Number of executions = 117
1038: Number of executions = 43
654: Number of executions = 43
814: Number of executions = 43

--然后在vi可以根据行数找到具体的sql语句(vi :line#)
Number of executions = 306
Number of compilations = 1
Worst preparation time (ms) = 32
Best preparation time (ms) = 32
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 = 0
Buffer pool data physical reads = 0
Buffer pool temporary data logical reads = 0
Buffer pool temporary data physical reads = 0
Buffer pool index logical reads = 0
Buffer pool index physical reads = 0
Buffer pool temporary index logical reads = 0
Buffer pool temporary index physical reads = 0
Buffer pool xda logical reads = 0
Buffer pool xda physical reads = 0
Buffer pool temporary xda logical reads = 0
Buffer pool temporary xda physical reads = 0
Total execution time (sec.microsec)= Not Collected
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 CREATE_TIME FROM SYSTOOLS.HMON_ATM_INFO WHERE SCHEMA = ? AND NAME = ? FOR UPDATE

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值