使用--group-by指纹,可以对使用“查询”命令的查询进行正确分组,但是将准备好的语句仅分组为一个类别,即“ Admin Execute”(执行)。
常规日志:
Tcp port: 3306 Unix socket: /mysql/MyHome/tmp/mysql.sock
Time Id Command Argument
2019-09-25T14:48:06.925515+09:00 135 Query select * from test.test
2019-09-25T14:48:41.350622+09:00 135 Query PREPARE stmt1 FROM ...
2019-09-25T14:48:41.352761+09:00 135 Prepare select * from test.test
2019-09-25T14:48:49.238776+09:00 135 Query execute stmt1
2019-09-25T14:48:49.238890+09:00 135 Execute select * from test.test
2019-09-25T14:48:51.534320+09:00 135 Query execute stmt1
2019-09-25T14:48:51.534410+09:00 135 Execute select * from test.test
2019-09-25T14:48:58.447376+09:00 135 Query select * from test.test
2019-09-25T14:48:59.471697+09:00 135 Quit
2019-09-25T14:49:06.176166+09:00 136 Connect root@localhost on using Socket
2019-09-25T14:49:06.176530+09:00 136 Query select @@version_comment limit 1
2019-09-25T14:49:06.177746+09:00 136 Query select USER()
2019-09-25T14:49:16.518483+09:00 136 Query set global general_log = 0
已分析的日志:
pt-query-digest general_query.log --type genlog --group-by fingerprint > parsed_general_query.log
# 140ms user time, 10ms system time, 25.20M rss, 200.72M vsz
# Current date: Wed Sep 25 17:41:29 2019
# Hostname: localhost
# Files: general_query.log
# Overall: 19 total, 12 unique, 0 QPS, 0x concurrency ____________________
# Time range: 2019-09-25T14:44:01.387437+09:00 to 2019-09-25T14:49:16.518483+09:00
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 0 0 0 0 0 0 0
# Query size 637 13 220 33.53 31.70 42.84 22.53
# Profile
# Rank Query ID Response time Calls R/Call V/M
# ==== ================================== ============= ===== ====== =====
# 1 0x95B7708AAF724467824B4A8EDAADA75C 0.0000 0.0% 6 0.0000 0.00 SELECT test.test
# 2 0x2A89113BB920BA301228F184663C8627 0.0000 0.0% 2 0.0000 0.00 ADMIN EXECUTE
# 3 0x036586A6BB9D1D6CB2F00D3322BD57C8 0.0000 0.0% 2 0.0000 0.00
# 4 0x77D39023988AC8743D932E4D05D8C1FE 0.0000 0.0% 1 0.0000 0.00
# 5 0x4F80EFE648FF2B95617710510A7CE0FF 0.0000 0.0% 1 0.0000 0.00 SET
# 6 0xCEE1D20CB103F13EE71D7852C493A0A8 0.0000 0.0% 1 0.0000 0.00 SET
# 7 0x7B48FAA9C951DD8A389FF9DA2DF3DF62 0.0000 0.0% 1 0.0000 0.00 SELECT
# 8 0x0E7680C04FF2596BE3A3649C5FAC418D 0.0000 0.0% 1 0.0000 0.00 SELECT
# 9 0xEDBC971AEC392917AA353644DE4C4CB4 0.0000 0.0% 1 0.0000 0.00 ADMIN QUIT
# 10 0x7417646A9FE969365D51E5F01B88B79E 0.0000 0.0% 1 0.0000 0.00 ADMIN CONNECT
# 11 0xDA556F9115773A1A99AA0165670CE848 0.0000 0.0% 1 0.0000 0.00 ADMIN PREPARE
# 12 0xA86446692DE3CA32943798A09019B333 0.0000 0.0% 1 0.0000 0.00 SHOW WARNINGS
# Query 1: 0 QPS, 0x concurrency, ID 0x95B7708AAF724467824B4A8EDAADA75C at byte 1263
...
# Tables
# SHOW TABLE STATUS FROM `test` LIKE 'test'\G
# SHOW CREATE TABLE `test`.`test`\G
# EXPLAIN /*!50100 PARTITIONS*/
select * from test.test\G
# Query 2: 0 QPS, 0x concurrency, ID 0x2A89113BB920BA301228F184663C8627 at byte 1263
...
administrator command: Execute\G
...
与此处相同,但准备的查询只是描述为“管理员命令:Execute \ G”。 在实际环境中,有很多准备好的语句,但它们被视为一种查询“ Admin Execute”。
作为时间方法,我只是将所有'Execute'替换为'Query',但这是不好的方法,因为有些查询不可用了... 我怎么解决这个问题?在pt-query-digest中是否有与此相关的选项,或以其他方式显示查询的统计信息?