Daily use of pt-query-digest
Pt-query-digest is a tool for analyzing mysql slow queries. It can analyze binlog, General log, slowlog, or MySQL protocol data captured by SHOWPROCESSLIST or tcpdump. It can be said that pt-query-digest is an artifact of mysql slow log analysis. Here are some common ways to use it:
Pt-query-digest has the most complete help information: pt-query-digest-- help
1. Analyze the entire slow query log:
Pt-query-digest-report slow.log
two。 Specify a point in time for analysis:
Pt-query-digest mysql-slow.log-20180907-- since '2018-09-07 08 until'-- 2018-09-07 08 until'--VLV 25
3. Analyze the most recent point-in-time query, such as an hour:
Pt-query-digest-- since=1h slow.log > temp_slow_log.log
4. Analysis points can be accurate to seconds, such as reporting slow queries for the last half hour:
Pt-query-digest-report-since 1800s slow.log > temp_slow_log.log
5. Analyze a slow query for a user:
Pt-query-digest-- filter'($event- > {user} | | ") = ~ m / ^ db _ user_name/i' slow.log > temp_slow_log.log
Combination (for users and time):
Pt-query-digest-- filter'($event- > {user} | | ") = ~ m / ^ db _ user_name/i' mysql-slow.log-- since '2018-10-27 1800 event- 0000'-- until '2018-10-27 2323 Suzhou 590000' > temp_slow_log.log
The work is too busy to update constantly.