mysql sql 行為的統計--一個很有用的指令碼

season0891發表於2012-03-14
The Binary log can provide valuable information about the frequency of per table DML statements.
This simple one line Linux command can provide valuable output:
$ mysqlbinlog /path/to/mysql-bin.000999 | \
 grep -i -e "^update" -e "^insert" -e "^delete" -e "^replace" -e "^alter" | \
 cut -c1-100 | tr '[A-Z]' '[a-z]' | \
 sed -e "s/\t/ /g;s/\`//g;s/(.*$//;s/ set .*$//;s/ as .*$//" | sed -e "s/ where .*$//" | \
 sort | uniq -c | sort -nr
 33389 update e_acc
 17680 insert into r_b
 17680 insert into e_rec
 14332 insert into rcv_c
 13543 update e_rec
 10805 update loc
 3339 insert into r_att
 2781 insert into o_att

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-718539/,如需轉載,請註明出處,否則將追究法律責任。

相關文章