Menu

PostgreSQL slow-query audit: a five-step evidence-first workflow (diagram)
πŸ“°

PostgreSQL slow-query audit: a five-step evidence-first workflow (diagram)

DEV Community: postgresΒ·Mhamed AskoureΒ·3 days ago
#2TLLpsPF
#devtopostgresql#devto#dev#index#postgresql
Long article (467 words) β€” no AI summary yet.
Reading 0:00
15s threshold

When a PostgreSQL-backed API, analytics dashboard or data pipeline gets slow, an index suggestion is not yet a diagnosis. I use a bounded, evidence-first workflow to separate what is observed from what is hypothesized .

1. Baseline β€” capture the actual plan safely

Record PostgreSQL version, workload and query purpose; remove sensitive literals. For approved, read-only SELECT queries, examine EXPLAIN (ANALYZE, BUFFERS) under representative conditions. ANALYZE executes the statement ; avoid unsafe runs, especially for writes.

Capture estimated versus actual rows, loops, sort operations, buffer reads/hits, observed runtime and relevant schema/index metadata. A single timing from an unmatched workload is not a baseline.

2. Diagnose β€” find what is expensive

Check sequential and index scans, selectivity, cardinality misestimates, heap fetches, I/O pressure, sorts and possible contention if relevant logs are available. For multi-tenant queries, sample both common and skewed tenant parameter values .

3.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.