美文网首页
通过二进制日志统计针对每个表执行的DML语句

通过二进制日志统计针对每个表执行的DML语句

作者: C86guli | 来源:发表于2017-03-15 14:29 被阅读19次

    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
    ...

    More details at http://ronaldbradford.com/blog/mysql-dml-stats-per-table-2009-09-09/

    转自:https://dev.mysql.com/doc/refman/5.7/en/binary-log.html

    相关文章

      网友评论

          本文标题:通过二进制日志统计针对每个表执行的DML语句

          本文链接:https://www.haomeiwen.com/subject/jwvlnttx.html