Command

EXPLAIN

PostgreSQL command that shows the planner's intended execution plan for a query without running it.

EXPLAIN reports the plan PostgreSQL would use to run a query — which scan it would pick, the join order, estimated row counts, and estimated cost. It does not execute the query, so the numbers are derived from planner statistics rather than measured times.

You run EXPLAIN to understand why a query is slow before changing it. The plan tells you whether PostgreSQL is doing a sequential scan instead of using an index, whether a join is a nested loop or a hash join, and how many rows it expects at each step.

Pair it with ANALYZE (EXPLAIN ANALYZE) to actually execute the query and capture real measurements alongside the estimates.