How to summarize Slow Query Log Files for MySQL

We can use mysqldumpslow to parses MySQL slow query log files and prints a summary of their contents. mysqldumpslow groups queries that are similar except for the particular values of number and string data values. It abstracts these values to N and 'S' when displaying summary output. The -a and -n options can be used to modify value abstracting behavior.
Invoke mysqldumpslow like this:
shell> mysqldumpslow [options] [log_file ...]

FormatOption FileDescription
-aDo not abstract all numbers to N and strings to S
-n numAbstract numbers with at least the specified digits
--debugdebugWrite debugging information
-g patternOnly consider statements that match the pattern
--helpDisplay help message and exit
-h nameHost name of the server in the log file name
-i nameName of the server instance
-lDo not subtract lock time from total time
-rReverse the sort order
-s valueHow to sort output
-t numDisplay only first num queries
--verboseverboseVerbose mode

$ mysqldumpslow --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


Popular posts from this blog

Check MySQL query history from command line