• 慢日志分析工具mysqldumpslow


    MySQL提供了慢日志分析工具mysqldumpslow

    查看mysqldumpslow帮助信息

    mysqldumpslow  --help

    1 [root@localhost~]# mysqldumpslow --help
     2 Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]
     3 
     4 Parse and summarize the MySQL slow query log. Options are
     5 
     6   --verbose    verbose
     7   --debug      debug
     8   --help       write this text to standard output
     9 
    10   -v           verbose
    11   -d           debug
    12   -s ORDER     what to sort by (al, at, ar, c, l, r, t), 'at' is default
    13                 al: average lock time
    14                 ar: average rows sent
    15                 at: average query time
    16                  c: count
    17                  l: lock time
    18                  r: rows sent
    19                  t: query time  
    20   -r           reverse the sort order (largest last instead of first)
    21   -t NUM       just show the top n queries
    22   -a           don't abstract all numbers to N and strings to 'S'
    23   -n NUM       abstract numbers with at least n digits within names
    24   -g PATTERN   grep: only consider stmts that include this string
    25   -h HOSTNAME  hostname of db server for *-slow.log filename (can be wildcard),
    26                default is '*', i.e. match all
    27   -i NAME      name of server instance (if using mysql.server startup script)
    28   -l           don't subtract lock time from total time
     1 -s, 是表示按照何种方式排序
     2 
     3     c: 访问计数
     4 
     5  
     6 
     7     l: 锁定时间
     8 
     9  
    10 
    11     r: 返回记录
    12 
    13  
    14 
    15     t: 查询时间
    16 
    17  
    18 
    19     al:平均锁定时间
    20 
    21  
    22 
    23     ar:平均返回记录数
    24 
    25  
    26 
    27     at:平均查询时间
    28 
    29  
    30 
    31 -t, 是top n的意思,即为返回前面多少条的数据;
    32 
    33 -g, 后边可以写一个正则匹配模式,大小写不敏感的;
    34 
    35  
    36 
    37 比如:
    38 
    39 得到返回记录集最多的10个SQL。
    40 
    41 mysqldumpslow -s r -t 10 /database/mysql/mysql06_slow.log
    42 
    43  
    44 
    45 得到访问次数最多的10个SQL
    46 
    47 mysqldumpslow -s c -t 10 /database/mysql/mysql06_slow.log
    48 
    49  
    50 
    51 得到按照时间排序的前10条里面含有左连接的查询语句。
    52 
    53 mysqldumpslow -s t -t 10 -g “left join” /database/mysql/mysql06_slow.log
    54 
    55  
    56 
    57 另外建议在使用这些命令时结合 | 和more 使用 ,否则有可能出现刷屏的情况。
    58 
    59 mysqldumpslow -s r -t 20 /mysqldata/mysql/mysql06-slow.log | more

     参考链接:https://blog.csdn.net/zlb_lover/article/details/81284267

  • 相关阅读:
    按月求收入和支出
    逆透视(Excel函数集团)
    九九乘法表新玩法(Excel函数集团)
    带条件的合并内容
    Word行高设置的最小值与固定值
    拆分成行(Excel函数集团)
    透视列(Excel函数集团)
    Delphi 生成前端TreeView Json数据
    postgres
    为什么就非得用手机app? 用网页不更方便?
  • 原文地址:https://www.cnblogs.com/liaopeng123/p/11350688.html
Copyright © 2020-2023  润新知