Database Reference
In-Depth Information
The general query log
The general query log is disabled by default. This is because the general query log,
when enabled, stores a record of every query MariaDB receives, including queries
that don't change any data. This is in contrast to the binary log, which only stores
queries that change data. On a busy server with lots of users, storing all queries can
lead to lots of huge log files very quickly. It is not usually necessary or recommended
to enable this log.
However, if we are trying to discover a hidden performance bottleneck or absolutely
need a record of everything the server is doing, this log can be enabled with the
general_log and general_log_file variables. The first is used to explicitly turn
the general log on ( =1 ) or off ( =0 ). The second configures where we want the log to
be and what we want it to be called. Here is an example:
general_log = 1
general_log_file = /var/log/mysql/mysql.log
If we are only interested in queries which change data, the only log we need to look
at is the binary log and we do not need to enable the general query log. As it says
in a comment in the default my.cnf file shipped with MariaDB, the general log is
a performance killer , so we should only enable it if we need to, and only for short
periods of time.
More information about the general query log can be found at https://mariadb.
com/kb/en/general-query-log/ .
The slow query log
The MariaDB slow query log, when enabled, contains a record of queries that take
longer than a configured amount of time to run. This log is very useful when tuning
and optimizing MariaDB as it stores lots of useful information such as the time it
took to execute a long query, the user who executed the query, the hostname the user
came from, and other details.
This log is disabled by default. To enable it we add the following to the [mysqld]
section of our my.cnf or my.ini config file:
slow_query_log = 1
There are four other variables that we use to control the behavior of the slow query
log. We use the slow_query_log_file variable to set the location of the log file. We
use the long_query_time variable to set the amount of time the query has to run
before MariaDB considers it to be slow. Times can be expressed in whole seconds
down to microsecond precision ( 0.000001 ).
 
Search WWH ::




Custom Search