Difference between revisions of "MySQL Query logging"

From Notes_Wiki
m
m
Line 1: Line 1:
<yambe:breadcrumb>Mysql configuration</yambe:breadcrumb>
=Query logging=
=Query logging=


Line 28: Line 29:




Back to [[Mysql configuration]]
<yambe:breadcrumb>Mysql configuration</yambe:breadcrumb>

Revision as of 08:09, 2 December 2012

<yambe:breadcrumb>Mysql configuration</yambe:breadcrumb>

Query logging

Logging all queries

We can log all queries that are received by server (even that have incorrect syntax) using 'log' option in '[mysqld]' section

[mysqld]
log

This can be very helpful on development machines for debugging.


Logging slow queries

Logging all queries can be problematic on production servers. Hence on production servers we can use:

long_query_time = 5
log_slow_queries
log_long_format

Here:

  • 'log_slow_queries' is used to log all queries which take more than 'long_query_time' seconds to execute. The minimum value of this parameter is 2, as mysql measures time with second accuracy.
  • 'log_long_format' will log additional information like which queries are not using indexes at all or not using indexes properly, etc.


More information about configurable parameters of mysql can be found in '/usr/share/doc/mysql-server-<version>'.


<yambe:breadcrumb>Mysql configuration</yambe:breadcrumb>