Get the App
SLTechnology News&Howtos  ›  Database  › 

Analyze the number of operations on the table during the time period

Shulou Source: shulou.com Published: 2022-06-01 09:08:02 10月03日 Update

Analyze the number of select, insert, update, delete of the table in a certain period of time. You need to use pt-query-digest, a tool in the percona-toolkit package, with the following script:

[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 "# 10x" / 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

Tags: Time time period number of times analysis tools scripts e.g. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker Shulou Technology Apple OPPO Reno