1. Introduction to Slow Queries
http://hllnihao.iteye.com/blog/1461472
2. Pt-query-digest Installation
http://blog.csdn.net/seteor/article/details/24017913
[Email protected]]# wget percona.com/get/pt-query-digest [[email protected]]# chmod u+x pt-query-digest
3. Use
(1) Direct Parse slow query file: PT-query-digest Slow.log >Slow_report.log (2) analyze queries within the last 12 Hours: PT-query-digest--since=12h slow.log >Slow_report2.log (3) Analysis of queries within a specified time range: PT-query-digest Slow.log--since'2014-04-17 09:30:00'--until'2014-04-17 10:00:00'> >Slow_report3.log (4) analysis refers to slow queries with SELECT statements PT-query-digest--filter'$event->{fingerprint} =~ m/^select/i'Slow.log>Slow_report4.log (5) Slow query for a user pt-query-digest--filter'($event->{user} | | "") =~ m/^root/i'Slow.log>Slow_report5.log (6query all all full-table scans or slow queries of the complete join PT-query-digest--filter'(($event->{full_scan} | | "") eq "yes") | | (($event->{full_join} | | "") eq "yes")'Slow.log>Slow_report6.log (7) Save the query to the Query_review table PT-query-digest--user=root–password=abc123--review h=localhost,d=test,t=query_review--create-review-Table Slow.log (8) Save the query to the Query_history table PT-query-digest--user=root–password=abc123--review H=localhost,d=test,t=query_ history--create-review-Table slow.log_20140401pt-query-digest--user=root–password=abc123--review h=localhost,d=test,t=query_history--create-review-Table slow.log_20140402 (9) Crawl the MySQL TCP protocol data through tcpdump and then analyze the tcpdump-S65535-x-nn-q-tttt-i any-c +Port3306>mysql.tcp.txtpt-query-digest--type tcpdump mysql.tcp.txt>Slow_report9.log (Ten) analysis Binlogmysqlbinlog MySQL-bin.000093> mysql-Bin000093.sqlpt-query-digest--type=binlog mysql-bin000093.sql >Slow_report10.log ( One) Analysis General Logpt-query-digest--type=genlog localhost.log >Slow_report11.log Official Document: http://www.percona.com/doc/percona-toolkit/2.2/pt-query-digest.html
MySQL Slow query analysis tool pt-query-digest