MySQL

Troubleshooting MySQL Issues: Daily Queries Every DBA Should Know

Essential MySQL diagnostic queries every DBA needs. Quickly identify slow queries, lock contention, replication lag, memory issues, and connection problems.

JusDB Team
October 4, 2022
Updated June 20, 2026
3 min read

MySQL DBAs face a wide range of daily challenges: from identifying slow queries to resolving lock contention, replication lag, memory bottlenecks, and connection issues. While monitoring tools provide dashboards, nothing replaces a set of reliable queries that give immediate insights into database health.

At JusDB, our MySQL Consulting, Performance Tuning, and High Availability services rely on these queries daily to troubleshoot issues in production environments.


1) Slow Queries

Slow queries are the root cause of most performance complaints. Enable the slow query log to capture problematic statements:

text
SET PERSIST slow_query_log = ON;
SET PERSIST long_query_time = 1;
SET PERSIST log_output = 'FILE';

Check queries currently executing:

text
SHOW FULL PROCESSLIST;

Identify top queries from the Performance Schema:

text
SELECT DIGEST_TEXT, COUNT_STAR, 
       ROUND(SUM_TIMER_WAIT/1e12,2) AS total_time_s,
       ROUND(AVG_TIMER_WAIT/1e9,2) AS avg_time_ms
FROM performance_schema.events_statements_summary_by_digest
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 10;

2) Locks and Blocking

Locks can cause application stalls if not monitored carefully. Use Performance Schema tables:

text
SELECT * FROM performance_schema.data_locks;
SELECT * FROM performance_schema.data_lock_waits;

Check for deadlocks:

text
SHOW ENGINE INNODB STATUS\G

3) Replication Issues

Replication lag can cause read inconsistencies. Verify replication status:

text
SHOW REPLICA STATUS\G

Worker-level details:

text
SELECT channel_name, worker_id, 
       LAST_APPLIED_TRANSACTION,
       APPLYING_TRANSACTION
FROM performance_schema.replication_applier_status_by_worker;

4) Connection and Thread Monitoring

Too many active connections can overload MySQL:

text
SHOW GLOBAL STATUS LIKE 'Threads_connected';
SHOW GLOBAL STATUS LIKE 'Threads_running';

Breakdown by client host:

text
SELECT host, COUNT(*) AS sessions
FROM information_schema.processlist
GROUP BY host;

5) Memory and Buffer Pool

Check buffer pool stats:

text
SHOW ENGINE INNODB STATUS\G

Identify top memory consumers:

text
SELECT event_name, current_alloc
FROM performance_schema.memory_summary_global_by_event_name
ORDER BY current_alloc DESC
LIMIT 10;

6) Disk Usage and Temporary Tables

Identify largest tables:

text
SELECT table_schema, table_name, 
       ROUND((data_length+index_length)/1024/1024,2) AS size_mb
FROM information_schema.tables
ORDER BY size_mb DESC
LIMIT 10;

Monitor temporary table usage:

text
SHOW GLOBAL STATUS LIKE 'Created_tmp%';

7) Errors and Crash Analysis

Check server error logs along with key runtime stats:

text
SHOW GLOBAL STATUS LIKE 'Aborted_%';
SHOW GLOBAL STATUS LIKE 'Connections';

Inspect recent InnoDB errors:

text
SHOW ENGINE INNODB STATUS\G

8) Daily DBA Checklist

  • ✅ Uptime check (SHOW GLOBAL STATUS LIKE 'Uptime')
  • ✅ Active queries (SHOW FULL PROCESSLIST)
  • ✅ Slow query digest (Performance Schema)
  • ✅ Replication lag (SHOW REPLICA STATUS)
  • ✅ Lock waits (data_locks, data_lock_waits)
  • ✅ Buffer pool hit ratio (InnoDB stats)
  • ✅ Temp tables and disk usage
  • ✅ Review error log for new warnings/deadlocks

9) How JusDB Helps

JusDB provides expert DBA services for troubleshooting, optimization, and automation. Our services include:


Conclusion

These daily DBA queries provide fast insight into MySQL’s runtime health. From diagnosing slow queries and locks to monitoring replication lag and buffer pool usage, they form the foundation of effective troubleshooting. Combined with proactive monitoring and automation, they help DBAs keep systems reliable and performant.

👉 If you’re facing recurring MySQL performance issues or need round-the-clock support, contact JusDB to learn how our Database Reliability Engineers can help.

Author: JusDB Database Reliability Engineering Team

Working with JusDB on MySQL Operations

These diagnostic queries are the starting point — interpreting what they tell you and knowing which lever to pull next is where experience matters. We provide on-call MySQL DBA support and performance troubleshooting as part of our managed database SRE service. Reach out if you need MySQL expertise on demand.

Related reading: MySQL Performance Tuning | MySQL Timeout Variables | MySQL Group Replication

Share this article

JusDB Team

Official JusDB content team

Keep reading

MySQL Explained (2026): InnoDB, 8.4 LTS, Replication & Production Patterns

Everything you need to know about MySQL: storage engines, replication topologies, performance tuning, and cloud deployment. From basics to advanced optimization.

MySQL5 minMay 13, 2026
Read

MySQL binlog Retention, Rotation & Purge: Production Guide (2026)

Configure MySQL binlog retention safely: binlog_expire_logs_seconds, manual purging rules, AWS RDS retention, and the disk-exhaustion failure mode you should monitor for.

MySQL10 minMay 9, 2026
Read

MySQL "Communications Link Failure": Fix wait_timeout, HikariCP & All 8 Timeout Variables

MySQL wait_timeout, net_read_timeout, innodb_lock_wait_timeout and max_execution_time — production tuning rules and the HikariCP alignment trick that prevents 'communications link failure' errors.

MySQL6 minMay 9, 2026
Read