暂无图片
有没有批量分析mysql慢日志的方法?
我来答
分享
白头叶猴
2023-01-16
有没有批量分析mysql慢日志的方法?

有台mysql服务器运行了30多个mysql服务,想每天看看有没有新增的慢sql,墨友有啥好办法吗?

mysqldumpslow好像无法指定时段

我来答
添加附件
收藏
分享
问题补充
3条回答
默认
最新
严少安
暂无图片

pt-query-digest 值得拥有

      --since
           type: string

           Parse only queries newer than this value (parse queries since this date).

           This option allows you to ignore queries older than a certain value and parse only those queries which are more recent than the value.  The value can be several
           types:

             * Simple time value N with optional suffix: N[shmd], where
               s=seconds, h=hours, m=minutes, d=days (default s if no suffix
               given); this is like saying "since N[shmd] ago"
             * Full date with optional hours:minutes:seconds:
               YYYY-MM-DD [HH:MM:SS]
             * Short, MySQL-style date:
               YYMMDD [HH:MM:SS]
             * Any time expression evaluated by MySQL:
               CURRENT_DATE - INTERVAL 7 DAY

           If you give a MySQL time expression, and you have not also specified a DSN for "--explain", "--processlist", or "--review", then you must specify a DSN on the
           command line so that pt-query-digest can connect to MySQL to evaluate the expression.

           The MySQL time expression is wrapped inside a query like "SELECT UNIX_TIMESTAMP(<expression>)", so be sure that the expression is valid inside this query.  For
           example, do not use UNIX_TIMESTAMP() because UNIX_TIMESTAMP(UNIX_TIMESTAMP()) returns 0.

           Events are assumed to be in chronological: older events at the beginning of the log and newer events at the end of the log.  "--since" is strict: it ignores all
           queries until one is found that is new enough.  Therefore, if the query events are not consistently timestamped, some may be ignored which are actually new
           enough.

           See also "--until".

暂无图片 评论
暂无图片 有用 2
暂无图片
JiekeXu
暂无图片

pt-query-digest 应该没问题的

暂无图片 评论
暂无图片 有用 2
H
hgb524

pt-query-digest 这个工具是大家都用的

暂无图片 评论
暂无图片 有用 0
hgb524
答主
2023-01-16
当然也是最好用的,百度一下用法就ok
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏