Conceptual
Login

When the Planner Has No Statistics It Just Guesses: Functions, LIKE and Range Conditions

Some conditions give the planner nothing to look up. A filter on a function call such as lower(email) = ? has no statistics unless an expression index exists, so the planner applies a fixed default guess. LIKE '%something%' and unbounded ranges get rough guesses too, and a join against a set-returning function is often assumed to produce a fixed number of rows regardless of reality. These hard-coded fallbacks are a separate cause of bad plans from stale or skewed statistics, and they are recognisable because the estimate is a suspiciously round fraction of the table.

Questions this Concept answers

  • Why does `LIKE '%term%'` receive a rough guess rather than a real estimate?