Debugging Slow API / Timeouts
When users report timeouts or the app feels "sluggish," the database is usually the prime suspect. Here's a workflow to prove it and fix it.
Workflow: Start from Latency
- Start with p95 Latency: In pgpulse, look for a spike in query latency that correlates with the User's reports.
- Correlate with Queries: Click into the spike to see which specific queries were running at that time.
- Identify the Cause:
- Locks: Was the query waiting for a lock?
- Scans: Was the query performing a sequential scan?
- IO: Was the system struggling to read data from disk?
- Fix and Verify: Apply the suggested fix and watch the latency metrics in pgpulse to confirm the "sluggishness" has subsided.