DB2 性能慢处理方法
原创
©著作权归作者所有:来自51CTO博客作者wx62e28ac222a20的原创作品,请联系作者获取转载授权,否则将追究法律责任
1.找到正在执行的应用程序
2.捕获单应用快照
db2 get snapshot for application agentid <apphandleid>
通过快照找到“Section number”、”Package name”和”Application creator”.分析时间戳,原则上找出只有”Statement start timestamp”而没有”Statement stop timestamp”时间戳的section,即没有结束的section片段。
3.通过db2expln工具收集包内执行计划
db2expln -d <dbname> -c <Application creator> -p <Package name> -i -g -o /tmp/<Package name>.out
4.分析/tmp/
.out输出文件,原则上找出没有结束的那个”Section number”
发现如下:
Section = 52
方法2:或者通过收集每个section对应的静态语句
db2 "select * from syscat.statements where pkgname='TR2002' and PKGSCHEMA='BTA' order by SEQNO" > /tmp/bta.TR2002.stmts.out
方法3:再或者通过db2bfd -h -s -v
.bnd或者所有静态语句和变量
5.检查确认执行计划准确性
db2 "select count(1) from bta.TINCOMETMP with ur"发现有147万条记录,所以包内统计信息是假的。
6.静态分析SQL
UPDATE tincometmp a SET a.f_sumincome=a.f_sumincome +
(select b.f_sumincome
from tincometmp b
where a.c_fundcode=b.c_fundcode and a.c_fundacco = b.c_fundacco
and a.c_tradeacco=b.c_tradeacco and b.d_cdate=?
WHERE a)
版权声明:本文为博主原创文章,未经博主允许不得转载。
Linux,oracle