Skip to main content

Monitoring

Performance Monitoring

Key Performance Metrics

  • Query Performance: Slow queries, query execution time

  • Connection Metrics: Active connections, aborted connections

  • Resource Usage: CPU, memory, disk I/O

  • Replication Lag: Master-slave synchronization delays

Monitoring Queries

sql
-- Check current connections
SHOW PROCESSLIST;
-- Monitor slow queries
SELECT * FROM mysql.slow_log ORDER BY start_time DESC LIMIT 10;
-- Check InnoDB status
SHOW ENGINE INNODB STATUS;
-- Monitor replication status
SHOW SLAVE STATUS\G

Performance Schema

sql
-- Enable Performance Schema
SET GLOBAL performance_schema = ON;
-- Monitor top queries by execution time
SELECT sql_text, exec_count, avg_timer_wait/1000000000 as avg_time_sec
FROM performance_schema.events_statements_summary_by_digest
ORDER BY avg_timer_wait DESC LIMIT 10;
-- Monitor table I/O
SELECT object_schema, object_name, count_read, count_write
FROM performance_schema.table_io_waits_summary_by_table
ORDER BY count_read + count_write DESC LIMIT 10;

Monitoring Tools

  • mysqladmin: Command-line monitoring utility

  • MySQL Workbench: GUI-based monitoring and administration

  • Third-party Tools: Percona Monitoring and Management (PMM)