Howto / Mysql
analyze slow query on mysql
Author: Katrame
Visits: 2736
Date: 12.06.2007
First of all check that slow query option is active:
# vi /etc/mysql/my.cnf
And search for this line:
log_slow_queries = /var/lib/mysql/query-slow.log
If present means that probably at /var/lib/mysql/ there's a file as:
-rw-r----- 1 root adm 4.9M 2007-06-12 10:45 query-slow.log
at this point we can start with mysqldumpslow tool where possible options are:
Author: Katrame
Visits: 2736
Date: 12.06.2007
# vi /etc/mysql/my.cnf
And search for this line:
log_slow_queries = /var/lib/mysql/query-slow.log
If present means that probably at /var/lib/mysql/ there's a file as:
-rw-r----- 1 root adm 4.9M 2007-06-12 10:45 query-slow.log
at this point we can start with mysqldumpslow tool where possible options are:
-v verbose
-d debug
-s=WORD
what to sort by (t, at, l, al, r, ar etc)
-r reverse the sort order (largest last instead of first)
-t=NUMBER
just show the top n queries
-a don't abstract all numbers to N and strings to 'S'
-n=NUMBER
abstract numbers with at least n digits within names
-g=WORD
grep: only consider stmts that include this string
-h=WORD
hostname of db server for *-slow.log filename (can be wildcard)
-i=WORD
name of server instance (if using mysql.server startup script)
-l don't subtract lock time from total time
Page 1 of 2
>>
Se vuoi discutere con noi su questo articolo o comunque vuoi porci delle domande usa il nostro Forum

