By default, administrative statements are not logged, nor are
queries that do not use indexes for lookups. This behavior can be
The time to acquire the initial locks is not counted as execution time. mysqld writes a statement to the slow query log after it has been executed and after all locks have been released, so log order might differ from execution order.
If the slow query log file is enabled but no name is specified,
the default name is
and the server creates the file in the same directory where it
creates the PID file. If a name is given, the server creates the
file in the data directory unless an absolute path name is given
to specify a different directory.
To include slow administrative statements in the statements
written to the slow query log, use the
option. Administrative statements include
OPTIMIZE TABLE, and
To include queries that do not use indexes for row lookups in the
statements written to the slow query log, use the
server option. See Section 5.1.3, “Server Command Options”. When such
queries are logged, the slow query log may grow quickly.
The server uses the controlling parameters in the following order to determine whether to write a query to the slow query log:
The server does not write queries handled by the query cache to the slow query log, nor queries that would not benefit from the presence of an index because the table has zero rows or one row.
Replication slaves do not write replicated queries to the slow query log, even if the same queries were written to the slow query log on the master. This is a known issue. (Bug #23300)
The slow query log should be protected because logged statements might contain passwords. See Section 18.104.22.168, “Passwords and Logging”.
The slow query log can be used to find queries that take a long time to execute and are therefore candidates for optimization. However, examining a long slow query log can become a difficult task. To make this easier, you can process a slow query log file using the mysqldumpslow command to summarize the queries that appear in the log. See Section 4.6.8, “mysqldumpslow — Summarize Slow Query Log Files”.
Copyright © 1997, 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices