千家信息网

分析时间段内对表的操作次数

发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,分析某个时间段内,表的select、insert、update、delete次数。需要用到percona-toolkit包中的一个工具pt-query-digest,脚本如下:[root@syk ~]
千家信息网最后更新 2025年02月02日分析时间段内对表的操作次数

分析某个时间段内,表的select、insert、update、delete次数。需要用到percona-toolkit包中的一个工具pt-query-digest,脚本如下:

[root@syk ~]# cat get_list.sh #!/bin/bashset -x#slow_file=ai-db1-slow.logslow_file=$1if [ $# != 1 ] ; then     echo "USAGE: $0 slow.log"     echo " e.g.: $0 api-db1-slow.log"     exit 1; fipt-query-digest --limit 10000 $slow_file > /tmp/tmp_filebn=`grep -n "#    1 0x" /tmp/tmp_file|awk -F ':' '{print $1}'`tn=`grep -n "# Query 1:" /tmp/tmp_file |awk -F ':' '{print $1}'`en=`expr $tn - 2`sed -n "$bn,$en"p /tmp/tmp_file > /tmp/table_filecat /tmp/table_file|awk '{print $6","$9","$10}' > /tmp/table_source/usr/local/mysql/bin/mysql -uroot -pxxxxxxxx -S /tmp/mysql_3308.sock <


0