Skip to main content

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

  1. Start with p95 Latency: In pgpulse, look for a spike in query latency that correlates with the User's reports.
  2. Correlate with Queries: Click into the spike to see which specific queries were running at that time.
  3. 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?
  4. Fix and Verify: Apply the suggested fix and watch the latency metrics in pgpulse to confirm the "sluggishness" has subsided.