Skip to content

brewDB EXPLAIN Plan Analysis

brewDB can run EXPLAIN against a query and turn Postgres’s output into a visual, interactive plan — something the legacy application had no equivalent of at all, since it had no query interface to begin with.

Interactive EXPLAIN plan tree with the self-time heatmap coloring and a flagged sequential scan node

You can run EXPLAIN two ways: as a real ANALYZE, which actually executes the query and reports real timings, or as plan-only, which shows Postgres’s planned execution strategy without running it. Either way, brewDB parses Postgres’s FORMAT JSON output into an interactive tree you can explore node by node, rather than reading raw JSON or text output.

Each node in the plan tree is colored by a self-time heatmap, making it easy to see at a glance which parts of the plan are consuming the most time relative to the rest of the query.

brewDB automatically flags common problem patterns in the plan, including:

  • Sequential scans
  • Misestimates
  • Disk sorts
  • Nested-loop blowups

Because ANALYZE actually executes the query, running it against a statement containing writes or DDL would apply those changes. brewDB’s write-guard catches this and offers a choice: run in a rolled-back transaction, so the query executes and reports real timings but nothing is committed, or fall back to explain-only, which shows the plan without running the query at all.