转自http://www.th7.cn/db/mysql/201507/113998.shtml

要想运行mysqldumpslow.pl(这是perl程序),下载perl编译器。下载地址:http://pan.baidu.com/s/1i3GLKAp

就是ActivePerl_5.16.2.3010812913.msi,一步一步安装后,将bin加入环境变量path。

现在假设一个场景:现场的slow.log拿回来了,要在本地的windows环境上的mysql上分析,如何处理?

C:/Program Files/MySQL/MySQL Server 5.6/bin>perl mysqldumpslow.pl --help
Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]
Parse and summarize the MySQL slow query log. Options are
--verbose verbose
--debug debug
--help write this text to standard output

-v verbose
-d debug
-s ORDER what to sort by (al, at, ar, c, l, r, t), 'at' is default
al: average lock time
ar: average rows sent
at: average query time
c: count
l: lock time
r: rows sent
t: query time
-r reverse the sort order (largest last instead of first)
-t NUM just show the top n queries
-a don't abstract all numbers to N and strings to 'S'
-n NUM abstract numbers with at least n digits within names
-g PATTERN grep: only consider stmts that include this string
-h HOSTNAME hostname of db server for *-slow.log filename (can be wildcard),
default is '*', i.e. match all
-i NAME name of server instance (if using mysql.server startup script)
-l don't subtract lock time from total time

1. -s,排序,c,t,l,r以及ac,at,al,ar分别是按照query次数,时间,lock时间,返回记录排序。加a就是倒序。
2. -t,top n,跟上数字就是算出top多少条
3. -g,跟正则表达式。

C:/Program Files/MySQL/MySQL Server 5.6/bin> mysqldumpslow.pl -r -s c -a -t > E:/slow.txt

如果执行这个会报错,就按照报错信息来,在my.ini中添加一些参数即可。分析的结果在slow.txt中,如下:

Count: 23 Time=505.55s (11627s) Lock=0.00s (0s) Rows=30740.8 (707039), username[password]@[10.194.172.41]
SELECT DISTINCT u.name,o.full_name FROM pub_user u,pub_user_org uo,pub_org o WHERE u.user_id=uo.user_id
AND uo.org_id=o.org_id and u.del_flag=N and uo.del_flag=N
and u.account not like 'S' and u.account not like 'S' group by u.user_id

Count: 4 Time=375.01s (1500s) Lock=0.00s (0s) Rows=10200.3 (40801), username[password]@[10.194.172.41]
select distinct username,pu.name, po.full_name from pub_login_history as plh
inner join pub_user as pu on plh.username=pu.user_id
inner join pub_user_org as puo on pu.user_id=puo.user_id
inner join pub_org as po on puo.org_id=po.org_id
where TIMESTAMPDIFF(MINUTE,login_time,logout_time)>=N
and login_time>'S' and login_time<'S'

Count: 4(执行了多少次) Time=375.01s(每次执行的时间) (1500s)(一共执行了多少时间) Lock=0.00s (0s)(等待锁的时间) Rows=10200.3(每次返回的记录数) (40801)(总共返回的记录数), username[password]@[10.194.172.41]

1014mysqldumpslow.pl简单分析慢日志 WINDOW平台的更多相关文章

  1. FFmpeg源代码简单分析:日志输出系统(av_log()等)

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  2. FFmpeg源代码简单分析:libavdevice的gdigrab

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  3. FFmpeg源代码简单分析:configure

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  4. FFmpeg资料来源简单分析:libswscale的sws_getContext()

    ===================================================== FFmpeg库函数的源代码的分析文章: [骨架] FFmpeg源码结构图 - 解码 FFmp ...

  5. FFmpeg源码简单分析:libswscale的sws_scale()

    ===================================================== FFmpeg的库函数源码分析文章列表: [架构图] FFmpeg源码结构图 - 解码 FFm ...

  6. FFmpeg源代码简单分析:libavdevice的avdevice_register_all()

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  7. FFmpeg源代码简单分析:makefile

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  8. FFmpeg源代码简单分析:libswscale的sws_scale()

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  9. FFmpeg源代码简单分析:libswscale的sws_getContext()

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

随机推荐

  1. 单源最短路径算法——Dijkstra算法

    #include <stdio.h> #include <stdlib.h> #include <string.h> /* run this program usi ...

  2. Neutron分析(5)—— neutron-l3-agent中的iptables

    一.iptables简介 1.iptables数据包处理流程 以本机为目的的包,由上至下,走左边的路 本机产生的包,从local process开始走左边的路 本机转发的包,由上至下走右边的路 简化流 ...

  3. NOIP2002字串变换[BFS]

    题目描述 已知有两个字串 A$, B$ 及一组字串变换的规则(至多6个规则): A1$ -> B1$ A2$ -> B2$ 规则的含义为:在 A$中的子串 A1$ 可以变换为 B1$.A2 ...

  4. AC日记——大整数加法 openjudge 1.6 10

    10:大整数加法 总时间限制:  1000ms 内存限制:  65536kB 描述 求两个不超过200位的非负整数的和. 输入 有两行,每行是一个不超过200位的非负整数,可能有多余的前导0. 输出 ...

  5. Unity热门插件推荐

    前言 Unite2015的笔记 ,本文所提到的扩展主要针对 mobile上使用. 文中资源在Asset Store描述的截图日期:2016-04-28 Mesh Baker https://www.a ...

  6. [Flash 3D] 又是一个难题解决了。(Flash3D在android中运行)

    做了一些away3D(4.1.6)+Flash cc,项目比较大,面数多达2000万个,发现电脑还有跑20多帧,可见away3d表现确实相当不错.想把这些东西放到手机上来看,却发现总是白屏,网上搜索了 ...

  7. Beanstalk消息队列的实现

    在工作中要用到消息队列,但是主管为了追求开发速度,让用了一个简易的类  beanstalk 下面来说明这个东西 参考博客:https://my.oschina.net/u/698121/blog/15 ...

  8. [No00004E]千万不要“拼命”工作——写在滴滴总裁柳青患癌症之后

    滴滴快的总裁柳青发内部信,透露自己检查出乳腺癌,她今年才37岁. 9月30日,就是国庆前一天,柳青发了内部信,透露了这个消息,她也说已经做完肿瘤摘除手术,"目前感觉还挺好的".她也 ...

  9. ubuntu系统下的防火墙使用

    apt-get install ufw      安装防火墙sudo ufw enable|disable|status         开启/关闭/查看防火墙状态sudo ufw allow 22/ ...

  10. netcore web.config ConnectionStrings AppSettings

    new ConfigurationBuilder().Build().GetSection("ConnectionStrings") new ConfigurationBuilde ...