1.可由以下query得知相關參數
show variables like "%slow_query_log%
2.開啟慢日誌(slow query log)
vi /usr/local/mysql/my.cnf
加入
slow_query_log=on #開啟
slow_query_log_file=mysql-slow #檔案名稱
long_query_time=2 #2s
3.慢查詢分析方法
官方:MySQLdumpslow
其他: pt-query-digest
4.log_queries_not_using_indexes
| Command-Line Format | --log-queries-not-using-indexes | ||
| System Variable Name | log_queries_not_using_indexes | ||
| Variable Scope | Global | ||
| Dynamic Variable | Yes | ||
| Permitted Values | |||
| Type | boolean | ||
| Default | OFF | ||
沒有留言:
張貼留言