#!/bin/sh for f in mysql-bin.[0-9]* do mysqlbinlog $f | awk ' /^use / { db=substr($2,1,index($2,"/")-1) } /^(INSERT|DELETE)/ { if ($2=="IGNORE") { table=$4 } else { table=$3 } if (index(table,".")<=0) table=db"."table printf("%s %s\n",$1,table) } /^(UPDATE|REPLACE)/ { table=$2 if (index(table,".")<=0) table=db"."table printf("%s %s\n",$1,table) } ' done | sort | uniq -c | sort -n | tail -10