Core conceptsintermediate

Table statistics (ANALYZE)

Sampled distributions of column values stored in pg_statistic that the planner uses to estimate row counts and choose plans.

What this means

Postgres doesn't re-count your whole table to plan a query, it keeps a sampled sketch of each column: which values are common, how they're spread out. ANALYZE builds that sketch, and the planner leans on it to guess how many rows a filter will match. Stale statistics are how good queries start choosing bad plans.

Why it matters operationally

Stale or missing statistics are a leading cause of sudden bad plans; ANALYZE is often the cheapest performance fix.

Related errors

Where it lives in the source

src/backend/commands/analyze.c

← All glossary terms · GUC reference · Error catalog