Get the App
SLTechnology News&Howtos  ›  Database  › 

Daily use of pt-query-digest

Shulou Source: shulou.com Published: 2022-06-01 09:13:04 10月04日 Update

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.

Tags: Analysis query time hour log user work usage method hee hee most complete accurate continuous information can be passed tools commonly used reports data artifact Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info MySQL Xiaomi OPPO Reno