To include slow administrative statements in the statements written to the slow query log, use the
log-slow-admin-statements
TABLE,
ANALYZE
REPAIR
TABLE.
To include queries that do not use indexes for row lookups in the statements written to the slow query
log, use the
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:
1. The query must either not be an administrative statement, or
statements
2. The query must have taken at least
not-using-indexes
lookups.
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 6.1.2.3, "Passwords and
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
summarize the queries that appear in the log. See
Slow Query Log
5.2.5. Server Log Maintenance
As described in
to help you see what activity is taking place. However, you must clean up these files regularly to ensure
that the logs do not take up too much disk space.
When using MySQL with logging enabled, you may want to back up and remove old log files from time
to time and tell MySQL to start logging to new files. See
On a Linux (Red Hat) installation, you can use the
MySQL from an RPM distribution, this script should have been installed automatically. Be careful with
this script if you are using the binary log for replication. You should not remove binary logs until you are
certain that their contents have been processed by all slaves.
On other systems, you must install a short script yourself that you start from
handling log files.
For the binary log, you can set the
files automatically after a given number of days (see
are using replication, you should set the variable no lower than the maximum number of days your
slaves might lag behind the master. To remove binary logs on demand, use the
statement (see
You can force MySQL to start using new log files by flushing the logs. Log flushing occurs when you
issue a
FLUSH LOGS
mysqldump
"FLUSH
Syntax",
Server Log Maintenance
[412]
TABLE,
CHECK
--log-queries-not-using-indexes
[412]
must have been specified.
[412]
must have been specified and the query used no indexes for row
Logging".
Files".
Section 5.2, "MySQL Server
Section 13.4.1.1,
"PURGE BINARY LOGS
statement or execute a
--flush-logs, or
mysqldump --master-data
Section 4.5.2,
"mysqladmin
server option. Administrative statements include
TABLE,
CREATE
INDEX,
[412]
long_query_time
Section 4.6.8,
Logs", MySQL Server can create several different log files
Section 7.2, "Database Backup
mysql-log-rotate
[450]
expire_logs_days
Section 5.1.4, "Server System
mysqladmin
— Client for Administering a MySQL
549
DROP
INDEX,
OPTIMIZE
server option. See
Section 5.1.3, "Server
--log-slow-admin-
[465]
seconds, or
--log-queries-
mysqldumpslow
"mysqldumpslow
script for this. If you installed
cron
system variable to expire binary log
PURGE BINARY LOGS
Syntax").
flush-logs,
mysqladmin
command. See
--
ALTER
TABLE, and
command to
— Summarize
Methods".
(or its equivalent) for
Variables"). If you
refresh,
Section 13.7.6.2,
Server", and
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers