← All notes

Read a PostgreSQL query plan with EXPLAIN

Short answer

Put EXPLAIN before a query to see the plan PostgreSQL picked: scan types, joins and cost estimates. EXPLAIN ANALYZE actually runs it and adds real timings, so wrap writes in a transaction you roll back. [S1][S2]

Reading it

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 14.1. Using EXPLAIN, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: EXPLAIN, PostgreSQL License.

Cite this

Permanent ID: iil:note:4vdatdpe

iinventedlight. 2026. "Read a PostgreSQL query plan with EXPLAIN." iinventedlight Library, iil:note:4vdatdpe, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-explain/. License: CC-BY-4.0.

@misc{iil_note_4vdatdpe,
  author = {{iinventedlight}},
  title = {{Read a PostgreSQL query plan with EXPLAIN}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-explain/},
  note = {Permanent ID iil:note:4vdatdpe. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-explain.md.