|
|
|
|
| 搜索 首页 |
MySQL 自带 slow log 的分析工具 mysqldumpslow ,但是没有说明。本文通过分析该脚本,介绍了其用法。 slow log 是 MySQL 根据 SQL 语句的执行时间设定,写入的一个文件,用于分析执行较慢的语句。 只要在 my.cnf 文件中配置好: log-slow-queries = [slow_query_log_filename] 即可记录超过默认的 10s 执行时间的 SQL 语句。 如果要修改默认设置,可以添加: long_query_time = 5 设定为 5s 。 如果要记录所有 SQL 语句,可以写入: log-long-format # t=time, l=lock time, r=rows # at, al, 以及 ar 是对应的平均值 mysqldumpslow 可以接受的参数有: 'v+', # verbose 'd+', # debug 's=s', # 排序 (t, at, l, al, r, ar etc) 'r!', # 倒排序 (largest last instead of first) 't=i', # 显示最高的 n 个查询 'a!', # 不把所有的数字以 N ,字符串以 'S' 显示 'n=i', # abstract numbers with at least n digits within names 'g=s', # grep: only consider stmts that include this string 'h=s', # hostname of db server for *-slow.log filename (can be wildcard) 'i=s', # name of server instance (if using mysql.server startup script) 'l!', # don't subtract lock time from total time < | >
|
|
|||||||||||
|
禅道
须在生活中修,在日常言语、形式里面契合、印证
自我的觉醒却是光阴偷不走,人拿不走的。 | ||||||
|
||||||