MySQL: How to figure out how many queries do you have that might affect I/O

From MyWiki

Jump to: navigation, search

We needed to figure out what are the most common queries are run on our MySQL server throughout the day that may affect I/O

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
Personal tools