How to monitor database performance
Updated 7/20/2026
The database is often the slowest part of an application. Monitoring shows you where the problems are before they get serious.
MySQL: what to watch
SHOW PROCESSLIST; # active queries
SHOW GLOBAL STATUS LIKE 'Threads_connected';
Enable the slow query log to find them, see MySQL optimization.
PostgreSQL: what to watch
SELECT * FROM pg_stat_activity; # connections and queries
SELECT * FROM pg_stat_database;
Important metrics
- Slow queries: those over 1 second, usually from a missing index.
- Connections: too many open connections can exhaust resources.
- Cache hit ratio: how often data is found in memory, not on disk.
Visual tools
Grafana has ready-made dashboards for MySQL and PostgreSQL, see Prometheus and Grafana.
When the database needs more
If queries are optimized but the database is still slow, it needs more RAM. With hourly billing you move to a bigger plan in minutes.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to monitor a website and SSL expiry
Do not let your site go down or your SSL certificate expire without knowing. Here is how to track them automatically.
Updated 7/20/2026Monitoring & loggingHow to monitor disk space and avoid running out
A full disk stops services and corrupts data. Here is how to track space and get alerts in time.
Updated 7/20/2026Monitoring & loggingHow to configure log rotation with logrotate
Logs grow forever and fill the disk. logrotate archives and deletes old ones automatically.
Updated 7/20/2026