Sitemap
Javarevisited

A humble place to learn Java and Programming better.

Member-only story

🧠 What is in PostgreSQL?

2 min read2 days ago

--

My articles are open to everyone; non-member readers can read the full article by clicking this link

  • is used to understand the execution plan PostgreSQL will follow for a SQL query.
  • It does not execute the query but estimates what the planner will do.
  • Useful for performance tuning, understanding indexes, row width, and costs.

🧪 Example Table

  • Table:
  • Columns: , ,
  • Indexed on: and , not on
  • Contains over 200 million rows

🔍 Key EXPLAIN Elements

  1. Sequential Scan
EXPLAIN SELECT * FROM grades;
  • Type: (full table scan)
  • Postgres scans every row.
  • Shown as:
Seq Scan on grades  (cost=0.00..289000.00 rows=200000000 width=31)

  • Startup cost (first number): Estimated cost to return the first row.
  • Total cost (second number): Estimated total cost to return all rows.
  • Measured in arbitrary units, usually milliseconds.
Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.

Ravindu Hirimuthugoda
Ravindu Hirimuthugoda

Responses (1)