Cost-based optimization
Query planner estimates the cost of alternative execution plans and chooses the cheapest.
Cost-based optimization contrasts with rule-based: instead of fixed rules, the planner uses statistics — table sizes, column distributions, available indexes — to estimate each candidate plan's cost, then picks the lowest. Ingres pioneered this in the 1980s; Informix, Sybase, and Oracle followed. It's slower to plan than rule-based heuristics but adapts as data evolves. A plan optimal for one dataset can be terrible for another; statistics tell the optimizer which. Modern systems blend both: statistics for critical decisions, rules to prune unlikely options and avoid expensive computations.