AIX下DB2数据库的SQL性能调试脚本

##使用eventor收集数据 ====
##设置工作参数
DB=dbname
WORKDIR=/home/event/
db2 connect to $DB
##创建event monitor
db2 "create event monitor evsql for statements write to file '$WORKDIR' replace"
##收集数据
##!/usr/bin/ksh

TIMESTAMP=`date +%H%M`
db2 connect to $DB
db2 set event monitor evsql state=1
##设置监控的时间,单位是秒
sleep 20
db2 set event monitor evsql state=0
db2evmon -db $DB -evm evsql > evsql.$DB.$TIMESTAMP.txt

#删除event monitor
db2 connect to $DB
db2 drop event monitor evsql

#result phase sample:
grep "Exec Time" evsql.$DB.$TIMESTAMP.txt |awk '{print $3}'|uniq|sort >sql.txt

你可能感兴趣的:(AIX下DB2数据库的SQL性能调试脚本)