MySQL Slow Query Log Enablement Checklist

halfbrain_logo512adminJune 19, 2026
1 lượt xem

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

  1. Confirm the performance symptom.
  2. Check whether slow query log is already enabled.
  3. Choose a conservative long_query_time value.
  4. Enable slow query logging safely.
  5. Generate or wait for the slow action.
  6. Review the slow query log.
  7. Identify table and query pattern.
  8. Disable or adjust logging if it becomes too noisy.
  9. Use findings for index, plugin or code review.
  10. Document the query pattern.

Reusable lesson

This applies to WordPress meta queries, WooCommerce, analytics dashboards, imports, search pages, cron jobs and reporting systems.

Checklist Type Log Analysis
Level Intermediate
Risk Level Medium Risk
Estimated Time 45–120 minutes

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

  1. Confirm symptom.
  2. Check slow log state.
  3. Choose threshold.
  4. Enable slow log.
  5. Reproduce action.
  6. Read log.
  7. Identify query pattern.
  8. Control log noise.
  9. Plan optimization.
  10. Document finding.

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/*

Share:

Disclaimer: The guides, checklists, commands, and examples on HalfBrain.net are provided for educational and operational reference only. Server environments, hosting providers, software versions, security settings, and WordPress configurations can vary, so you should always review commands before running them on your own system. We do our best to keep the content accurate and useful, but we cannot guarantee that every command, configuration, or recommendation will fit every environment. Always back up your website, database, and server configuration before making changes. HalfBrain.net is not responsible for data loss, downtime, security incidents, misconfiguration, or other issues that may result from applying the information on this website. Use the material at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *