Skip to content

Instantly share code, notes, and snippets.

@kevinbin
Created November 17, 2012 07:09
Show Gist options
  • Save kevinbin/4093953 to your computer and use it in GitHub Desktop.
Save kevinbin/4093953 to your computer and use it in GitHub Desktop.
统计binlog中每个表的DML数量
mysqlbinlog mysql-bin.000045 | \
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment