Slow Query Logs
This page is part of MariaDB's Documentation.
The parent of this page is: Log Archive
Topics on this page:
Overview
Slow Query Logs record database queries of concern based on logging rules.
Compatibility
Multi-Node Analytics
Replicated Transactions
Single Node Analytics
Single Node Transactions
Configuration Manager
Slow query logging is disabled by default.
To enable and configure slow query logging:
Prepare a Configuration Manager configuration:
Set the
slow_query_log
parameter to1
to enable slow query logging. The default,0
, disables slow query logging.If needed, set the
long_query_time
parameter to the threshold in seconds which will trigger logging based on query runtime. long_query_ defaults vary by service.time
After a configuration has been prepared with the intended parameters, it must be applied to the desired service for this change to take effect. The service will be restarted when the configuration is applied.
Log Archive
Slow Query Log data is available in the Log Archive.
To download log data:
Log in to the MariaDB SkySQL portal.
Access "Monitoring" in left navigation.
From SkySQL Monitoring, access "Logs" in left navigation.
Select the desired server(s), log types (such as "Slow Query Log"), and time frame, then click the "Download" button to download the logs.
Log files can be downloaded in your choice of JSON and/or Slow Query plain text formats.
The downloaded
.zip
archive will contain one file per server, log, day, and format.
Data Retention
The Log Archive retains log data for 7 years. Data is retained even if the SkySQL service is deleted.
Logs are stored in GCS buckets with HTTPS data-in-transit encryption and Google default (AES256) data-at-rest encryption.
Logs are stored by day, by service, by server, by log type.
To request log data expungement, submit a Support Request.
Data retention requirements vary by business. A business process may be needed to download Slow Query Log data in support of your data retention requirements.
Log Format
Fields
Slow Query Log lines vary in structure and content.
Informational lines begin with #
Plain Text
When downloaded in plain text format, Slow Query Log data is as outputted by the database server.
JSON
When downloaded in JSON format, Slow Query Log data has this format for each line, incorporating the plain text format:
{"log":"PLAIN_TEXT","offset":OFFSET_VALUE}
One JSON object is produced for each logical line from the original plain text log file.
JSON key order is not guaranteed.