Database Monitoring in New Relic: Slow Queries and Connection Problems
When an application is slow, the database is often involved. New Relic gives two complementary views: what the application sees, and what the database itself reports.
From the Application (APM)
APM agents capture database calls inside transactions:
- Time spent in the database per transaction
- Slowest queries (with obfuscated SQL)
- Query counts per request — spotting N+1 query problems
- Explain plans for slow queries (where supported)
From the Database (Integrations)
On-host integrations and cloud integrations report database health:
- MySQL / PostgreSQL — connections, queries per second, slow queries, replication lag, locks
- MongoDB — operations, replication, cache usage
- Redis — memory, hit rate, evictions, connected clients
- Cloud databases — RDS, Azure SQL, Cloud SQL metrics
Common Problems and Signals
| Problem | Signal |
|---|---|
| Missing index | One query dominates DB time |
| N+1 queries | Hundreds of identical queries per request |
| Connection pool exhaustion | Requests waiting, timeouts |
| Lock contention | Rising lock waits |
| Replication lag | Stale reads on replicas |
| Cache misses | Low Redis hit rate, DB load spikes |
Useful Query
SELECT average(databaseDuration) FROM Transaction
WHERE appName = 'orders-api' FACET name SINCE 1 hour ago LIMIT 10
Alerts
- Connection usage > 80% of max
- Replication lag over threshold
- Database time per transaction rising
Before scaling servers, look at the queries. One index often beats ten new instances.