Configuration of the Slow Query Monitor first requires that slow query logging is enabled. This can be accomplished in one of three ways.
As of version 5.1.29, the following options may be used:
Option | Sample Value | Required | Note |
---|---|---|---|
slow_query_log | 1 | Yes, defaults to 0 | 1 enables the log, 0 disables it |
slow_query_log_file | C:\Program Files\MySQL\slow_query.log | Yes, defaults to hostname-slow.log | Any path name is acceptable |
long_query_time | 0.5 | Yes, defaults to 10 | Units are in seconds, can also use 0 or microseconds |
log_short_format | FALSE | Yes, defaults to FALSE | Must be set to FALSE |
log_slow_admin_statements | OFF | No, defaults to OFF | Logs admin statements like ANALYZE, OPTIMIZE, ALTER TABLE, etc. |
log_queries_not_using_indexes | ON | No, defaults to OFF | Logs queries expected to retrieve all rows |
log_slow_slave_statements | OFF | No, defaults to OFF | Logs statements on a replication slave server |
min_examining_row_limit | 0 | No, defaults to 0 | Logs statements that have examined minimum # of rows |
See section 5.2.5 of the online MySQL documentation for more information on the slow query log specific to your version. Some of these properties may become deprecated in future versions or not exist in versions before 5.1.12.
Additionally, it is important to understand that the server does not write queries handled by the query cache to the slow query log, nor does it write queries that would not benefit from the presence of an index as the table has either zero or one row. Also of note is that the server does not automatically rotate the slow query log. If you wish to rotate your log file, you may simply delete or rename the current log file manually or with a utility program and the server will create a new log file itself. It is recommended you do this at a period of low activity so as to not cause the agent to miss reading important data.
© ALL RIGHTS RESERVED. Feedback Terms of Use Privacy Cookie Preference Center