MySQL Slow Query Log Enablement Checklist
The slow query log helps identify queries that take too long. It is useful for diagnosing slow WordPress admin pages, plugin queries, reports, imports and database-heavy application actions.
Core principle
Performance tuning should start with evidence. Slow query logging helps you find which query is slow instead of guessing which plugin or table is guilty.
Checklist
- Confirm the performance symptom.
- Check whether slow query log is already enabled.
- Choose a conservative long_query_time value.
- Enable slow query logging safely.
- Generate or wait for the slow action.
- Review the slow query log.
- Identify table and query pattern.
- Disable or adjust logging if it becomes too noisy.
- Use findings for index, plugin or code review.
- Document the query pattern.
Reusable lesson
This applies to WordPress meta queries, WooCommerce, analytics dashboards, imports, search pages, cron jobs and reporting systems.
When to Use This Checklist
Use this checklist when diagnosing slow MySQL queries behind WordPress, dashboards, APIs, admin pages or imports.
Required Tools
MySQL admin access, SSH access, slow query log path, affected page or action, backup of config
Before You Start
Do not leave noisy slow query logging unmanaged on a small disk. Monitor log size after enabling.
Structured Checklist Steps
- Confirm symptom.
- Check slow log state.
- Choose threshold.
- Enable slow log.
- Reproduce action.
- Read log.
- Identify query pattern.
- Control log noise.
- Plan optimization.
- Document finding.
Verification Steps
- Slow query log captures relevant data.
- Slow query pattern is identified.
- Log size is controlled.
- Optimization target is evidence-based.
- Config change is documented.
Rollback Plan
If slow query logging creates excessive disk usage, disable or raise the threshold and rotate the log before continuing analysis.
Common Mistakes
- Guessing slow queries without logs.
- Leaving log growth unchecked.
- Using too low threshold on busy sites.
- Not connecting query to application action.
- Adding indexes without query evidence.
Related Commands
mysql -u root -p -e "SHOW VARIABLES LIKE 'slow_query_log';"
mysql -u root -p -e "SHOW VARIABLES LIKE 'long_query_time';"
mysql -u root -p -e "SET GLOBAL slow_query_log = 'ON';"
mysql -u root -p -e "SET GLOBAL long_query_time = 2;"
sudo tail -n 100 /var/log/mysql/mysql-slow.log
sudo du -sh /var/log/mysql/*