Managing General and Slow Query Logs on the DB System
You can manage and purge general and slow query logs on the MySQL HeatWave DB system.
By default, general log and slow query log are disabled on the DB system.
- General log is stored in the
mysql.general_logtable. - Slow query log is stored in the
mysql.slow_logtable.
On MySQL HeatWave DB systems, slow logging is configured per MySQL instance. The primary logs its own slow queries only if slow logging is enabled on the primary. Each read replica logs its own slow queries only if slow logging is enabled on that replica. Logs are not automatically consolidated across primary and replicas, so they must be checked per instance. The slow query log does not capture every executed query. It only records queries that meet the slow query log criteria, such as queries that exceed the duration specified by the long_query_time variable.
To capture every executed query, you must use the general log. The general query log records all SQL statements received by the MySQL server from connected clients. On a read replica, the general log records statements received directly by the replica, it does not record statements that come from the primary.
As there is no default retention period for these logs, they remain on the DB system until you purge them.
Estimating General and Slow Query Log Size
Estimate the size of the general log and slow query log tables.
These queries return a rough size estimate only. They do not the return the exact size of the logs. They may return an incorrect size estimate if the log has been truncated previously.
Purging General and Slow Query Logs
Purge the general log and slow query log tables.
The following commands truncate the entire log table. If you want to retain some information or history from the log table, you must copy the required information to another table before truncating the log.
For read replicas, the slow logs are managed per MySQL instance. You cannot truncate the query log table directly on a read replica because read replicas run in read-only mode. To truncate the query log table on read replicas, run the truncate command on the source MySQL server or writable endpoint of the DB system. The statement is replicated and applied on the read replicas.