P50 28s Analyze →
↩ All field notes
Querk · Field notes

Reading EXPLAIN ANALYZE Without a DBA: A 15-Minute Guide

Published November 23, 2026 · Querk — Postgres review pipeline

When a PostgreSQL query slows down, the first place to look is EXPLAIN ANALYZE. The output can look intimidating, but most performance problems trace back to a handful of recurring plan shapes. A developer does not need a DBA to spot them. This guide walks through four patterns that explain the majority of slow queries, what each one means, and where to look first.

1. Sequential Scan on a Large Table

A Seq Scan means PostgreSQL read every row in a table. On a small table this is fine; on a large table it is usually the root cause. Look at the actual rows and actual time columns. If the plan scans millions of rows to return a handful, the query likely lacks a usable index on the filtered column. Adding an index often turns a sequential scan into an index scan, but only if the query’s WHERE clause can use it.

2. Nested Loop Join with High Row Counts

Nested Loop joins work well when one side is small and the other is indexed. They become expensive when both inputs are large or unindexed. In EXPLAIN ANALYZE, check the actual rows for each side of the join. If the inner side is scanned repeatedly for every outer row, cost multiplies quickly. Rewriting the join, adding indexes on join keys, or letting the planner choose a hash or merge join can reduce repeated scans.

3. Sort Operations Spilling to Disk

A Sort node that shows “Disk:” in the actual time or memory statistics means work_mem was too low for the operation. PostgreSQL wrote temporary files to disk, which is orders of magnitude slower than memory. The fix is not always to raise work_mem globally; sometimes the query can avoid sorting altogether with an index that matches the ORDER BY clause, or by reducing the result set before sorting.

4. Index Scan Returning Too Many Rows

An Index Scan is not automatically fast. If the plan shows an index scan returning a large fraction of the table, PostgreSQL may be bouncing between the index and the heap for too many rows. In these cases, a sequential scan might actually be cheaper. Look at the actual rows versus rows returned by the query. If the index is not selective enough, consider a covering index or adjusting the query to filter earlier.

Reading EXPLAIN ANALYZE is a pattern-recognition skill. Once a developer recognizes sequential scans, expensive nested loops, disk-based sorts, and unselective index scans, most slow queries become straightforward to fix. Querk can surface these plan nodes automatically, but the underlying logic is the same: compare estimated rows to actual rows, and watch for operations that scan more data than necessary.

Paste your slowest query — 3 free reviews, no signup. Index DDL, rewrites, write-path impact, and a verification command back in ~30 seconds. Analyze a query →