PostgreSQL EXPLAIN guide

Sequential Scan in PostgreSQL EXPLAIN

A Sequential Scan reads table pages in sequence. It is not automatically a problem: PostgreSQL often chooses it correctly when a query needs much of a table or when the relation is small.

Example EXPLAIN output

Seq Scan on events
  Actual Rows: 2,450,000
  Rows Removed by Filter: 31
  Actual Total Time: 205.1 ms

What PostgreSQL is telling you

The planner chose a Seq Scan for the relation.

EXPLAIN ANALYZE shows the real rows and time spent.

Filters and Rows Removed by Filter show how much scanned work was discarded.

What it can mean

Large scans that return very few rows deserve investigation.

Fast sequential scans can be perfectly healthy.

An index is useful only when its access pattern is actually cheaper than reading the table.

What to check next

Relation size and actual rows scanned.

Rows removed by filter.

Filter selectivity.

Existing indexes and their column order.

Whether statistics are current.

When this is not automatically a problem

  • • Whole-table reporting queries.
  • • Small relations.
  • • Queries returning a large percentage of rows.

Check your actual plan

PlanCheck analyzes TEXT or JSON locally in your browser. Your SQL and plans are not uploaded.

Analyze EXPLAIN output