Slow Query Log Contents 1064 The Slow Query Log To include slow administrative statements in the slow query log, enable the log_slow_admin_statements  system variable. Administrative statements include  ALTER TABLE , ANALYZE TABLE ,  CHECK TABLE ,  CREATE INDEX ,  DROP INDEX ,  OPTIMIZE TABLE , and  REPAIR TABLE . To include queries that do not use indexes for row lookups in the statements written to the slow query log, enable the  log_queries_not_using_indexes  system variable. (Even with that variable enabled, the server does not log queries that would not benefit from the presence of an index due to the table having fewer than two rows.) When queries that do not use an index are logged, the slow query log may grow quickly. It is possible to put a rate limit on these queries by setting the  log_throttle_queries_not_using_indexes system variable. By default, this variable is 0, which means there is no limit. Positive values impose a per- minute limit on logging of queries that do not use indexes. The first such query opens a 60-second window within which the server logs queries up to the given limit, then suppresses additional queries. If there are suppressed queries when the window ends, the server logs a summary that indicates how many there were and the aggregate time spent in them. The next 60-second window begins when the server logs the next query that does not use indexes. The server uses the controlling parameters in the following order to determine whether to write a query to the slow query log: The  log_timestamps  system variable controls the time zone of timestamps in messages written to the slow query log file (as well as to the general query log file and the error log). It does not affect the time zone of general query log and slow query log messages written to log tables, but rows retrieved from those tables can be converted from the local system time zone to any desired time zone with  CONVERT_TZ()  or by setting the session  time_zone  system variable. By default, a replica does not write replicated queries to the slow query log. To change this, enable the  log_slow_slave_statements  system variable. Note that if row-based replication is in use ( binlog_format=ROW ),  log_slow_slave_statements  has no effect. Queries are only added to the replica’s slow query log when they are logged in statement format in the binary log, that is, when binlog_format=STATEMENT  is set, or when  binlog_format=MIXED  is set and the statement is logged in statement format. Slow queries that are logged in row format when  binlog_format=MIXED  is set, or that are logged when  binlog_format=ROW  is set, are not added to the replica’s slow query log, even if log_slow_slave_statements  is enabled. When the slow query log is enabled, the server writes output to any destinations specified by the log_output  system variable. If you enable the log, the server opens the log file and writes startup messages to it. However, further logging of queries to the file does not occur unless the  FILE  log destination is selected. If the destination is  NONE , the server writes no queries even if the slow query log is enabled. Setting the log file name has no effect on logging if  FILE  is not selected as an output destination. 4. The query must not be suppressed according to the log_throttle_queries_not_using_indexes  setting. 3. The query must have examined at least  min_examined_row_limit  rows. 2. The query must have taken at least  long_query_time  seconds, or log_queries_not_using_indexes  must be enabled and the query used no indexes for row lookups. 1. The query must either not be an administrative statement, or  log_slow_admin_statements  must be enabled.