Planner & statistics

Extended statistics

Also called: CREATE STATISTICS, multivariate statistics

Normally PostgreSQL studies each column on its own. Extended statistics, created with CREATE STATISTICS, tell it to study several columns together so it learns that they are related, for example that city and country move together.

What this means

By default Postgres studies each column on its own, so it can't tell that city and country move together, it treats them as independent and under-counts rows when you filter on both. Extended statistics, made with CREATE STATISTICS, tell it to study the columns as a group, so that hidden link stops fooling the planner.

Why it matters operationally

Without it, the planner assumes columns are independent and multiplies their selectivities, badly under-counting correlated filters like city = 'Paris' AND country = 'France'. Extended statistics fix a whole class of join-order and row-estimate disasters on real-world schemas.

Related & next

Mentioned from

← All glossary terms · GUC reference · Error catalog