The time to acquire the initial table 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.
Before MySQL 4.1, if you also use
--log-long-format when logging slow
queries, queries that are not using indexes are logged as well.
Starting with MySQL 4.1, logging of queries not using indexes for
row lookups is enabled using the
option instead. The
--log-long-format is deprecated as
of MySQL 4.1, when
--log-short-format was introduced,
which causes less information to be logged. (The long log format
is the default setting since version 4.1.) See
Section 5.1.2, “Server Command Options”.
In MySQL 4.0, slow administrative statements such as
ANALYZE TABLE, and
ALTER TABLE were written to the
slow query log. This logging was disabled in MySQL 4.1 until
4.1.13, when the
option was added to specify logging of slow administrative
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 22.214.171.124, “Administrator Guidelines for Password Security”.
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.7, “mysqldumpslow — Summarize Slow Query Log Files”.