From: Progfou Date: Mon, 5 Mar 2012 19:43:11 +0000 (+0700) Subject: Outil de recherche des 10 requêtes MySQL les plus fréquentes. X-Git-Url: https://git.auf.org/?p=progfou.git;a=commitdiff_plain;h=60d739e2c4f9c765ccffe2b9d5c124035f23edb6;ds=sidebyside Outil de recherche des 10 requêtes MySQL les plus fréquentes. --- diff --git a/sysadmin/mysqlbinlog-top10 b/sysadmin/mysqlbinlog-top10 new file mode 100755 index 0000000..2a523aa --- /dev/null +++ b/sysadmin/mysqlbinlog-top10 @@ -0,0 +1,19 @@ +#!/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