¶
MySQL slow query log¶
The MySQL slow query log is a logging capability provided by MySQL that records queries which take longer than a specified threshold to execute.^[600-developer__database__mysql__mysql-index.md] Analyzing this log helps database administrators identify inefficient queries and potential performance bottlenecks.
Configuration¶
The status and configuration of the slow query log can be checked and modified using SQL commands.
To view the current configuration settings:
show variables like '%slow_query_log%';
To enable the log dynamically for the current running instance:
set global slow_query_log=1;
For a persistent configuration that survives a server restart, the setting must be added to the MySQL configuration file (e.g., my.cnf):
slow_query_log = 1
Related Concepts¶
- [[MySQL]]
- [[Query optimization]]
- [[Database indexing]]
Sources¶
600-developer__database__mysql__mysql-index.md