转自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. mysql 二进制文件增量备份

    1.首先在my.cnf下添加二进制文件路径(windows下文件名称为my.ini) 在[mysqld]下添加 log-bin=mysql-bin 2.centos下默认安装mysql 5.6,数据默 ...

  2. Interlocked系列函数线程同步的缺陷

    1. Code int Work() { while (m_lInterlockedData < 10) { InterlockedIncrement(&m_lInterlockedDa ...

  3. Jetty使用攻略

    jetty作为一款小型的web容器用处很大,因为其小巧强大,经常作为嵌入式的组件处理http交互. Jetty 作为一个独立的 Servlet 引擎可以独立提供 Web 服务,但是它也可以与其他 We ...

  4. windows 7 语言切换 Vistalizator

    Try Vistalizator - this tool allows you to change display language in Windows editions other than (o ...

  5. lca入门———树上倍增法(博文内含例题)

    倍增求LCA: father[i][j]表示节点i往上跳2^j次后的节点 可以转移为 father[i][j]=father[father[i][j-1]][j-1] 整体思路: 先比较两个点的深度, ...

  6. JavaScript数组定义

    数组有四种定义的方式 使用构造函数: var a = new Array(); var b = new Array(8); var c = new Array("first", & ...

  7. Openvpn 公网访问内网

    对于需要从公网访问内网的情况, 需要做如下配置 从公网到内网 除了设置net.ipv4.ip_forward = 1 以外, 还需要设置iptables, 增加两行forward # Generate ...

  8. Tstringlist分割字符串的用法?

    TStrings是一个抽象类,在实际开发中,是除了基本类型外,应用得最多的. 常规的用法大家都知道,现在来讨论它的一些高级的用法. 1.CommaText 2.Delimiter &Delim ...

  9. Java 集合系列06之 Vector详细介绍(源码解析)和使用示例

    概要 学完ArrayList和LinkedList之后,我们接着学习Vector.学习方式还是和之前一样,先对Vector有个整体认识,然后再学习它的源码:最后再通过实例来学会使用它.第1部分 Vec ...

  10. ASP.NET MVC验证 - 自定义验证规则、验证2个属性值不等【待验证】

    提示:保存后才提示错误信息 自定义验证特性,继承ValidationAttribute并实现IClientValidatable 这次重写了基类的IsValid()方法的另外一个重载,因为该重载包含了 ...