Logging Queries
On this page
SingleStore supports logging all or specific queries in a general query log by configuring engine variables.query.
file, which typically resides in the /var/lib/memsql/<nodeID>/tracelogs
directory.
Configuration Parameters for Query Logging
general_
: Controls whether database queries are logged.
-
OFF
(default): No queries are logged. -
PARTIAL
: Logs only a subset of the queries running through the system.This mode is designed for minimal overhead: if multiple queries are trying to write to the query log simultaneously, only one will succeed and the other writes will be abandoned. -
ON
: Every query running through the system is logged.This mode has a significantly negative impact on performance as query execution now depends on writes to the trace log.
To log user queries, you can set the general_
variable on all aggregator nodes.
-
general_
: Specifies the file in which connections and queries are logged.log_ file By default, this variable is set to /var/lib/memsql/tracelogs/query.
.log For query logging to take place, general_
must be set tolog ON
orPARTIAL
, depending on your requirements. -
minimal_
: Defines the minimal disk space in MB, which, when reached on the disk where the data directories (such as logs, snapshots, blobs, plancache, auditlogs, and tracelogs) are mounted, SingleStore will halt new write queries.disk_ space As query log files can potentially grow in size until the disk limit is reached, it is important to monitor this configuration. -
tracelogsdir
: The path to the log destination directory, which contains thequery.
file among others.log By default, this variable points to the /var/lib/memsql/<nodeID>/tracelogs
directory.
Note: If a query includes Remote Procedure Call (RPC) data, the RPC data is logged as a JSON string rather than query text.
Rotating Query Log to Manage its Size
Query logs can generate large files over time and may require a log rotation policy to be implemented.query.
file can be rotated by moving the query.
file and then sending SIGHUP
to the memsqld
process.query.
and continue writing.query.
is a text file, you may want to compress the file after rotation to free up disk space.
For an illustration of the query.
file rotation, refer to Rotating Trace Log to Manage its Size.
Last modified: June 22, 2022