Database query path
Core details
Repeatable workflow
- Find query text — slow query log,
pg_stat_statements(Postgres) or vendor equivalent. - EXPLAIN (ANALYZE) — estimated vs actual rows; huge gap ⇒ stale statistics or bad parameter sniffing class issues.
- Access path — seq scan vs index vs bitmap; why did the optimizer choose it?
- Locks / waits —
pg_locks, wait events—low CPU + high latency often waiting, not “slow query.” - Replica vs primary — read-your-writes and lag; intermittent “bugs” may be stale replica.
Write-path awareness
Indexes speed reads and cost writes. Hot updates on wide indexes → bloat and contention.
Understanding
“Add an index” without plan proof is index theater. Often the fix is narrower SELECT, batching, keyset pagination, or fresh stats—not more B-trees.
Senior understanding
| Symptom | First split |
|---|---|
| High latency, low DB CPU | locks, disk, replication lag, pool wait |
| Plan flips across days | stats, skew, prepared statement plans |
Deep relational + caching narrative: /databases and Indexing & query tuning.
Diagram
Loading diagram…
See also
Last updated on
Spotted something unclear or wrong on this page?