IT lexicon › Database › Cost Model

Cost Model

Database På svenska → Updated: 2026-11-12

The mathematical model a query optimizer uses to estimate the CPU and I/O cost of different execution plans.

A query optimizer must compare candidate plans for the same query, choosing the cheapest. It does this through a cost model—formulas that estimate CPU cycles, I/O operations, and memory required for each operator. The cost model relies on statistics about table sizes, index distributions, column cardinality, and selectivity (what fraction of rows a WHERE clause filters out).

Query optimization from the 1980s onward revolved largely around improving cost models. An underestimating model leads to slow chosen plans; an overestimating model wastes CPU exploring unnecessary alternatives. Modern systems like PostgreSQL employ sophisticated cost models accounting for CPU cache effects, I/O sequentiality, and even multi-core parallelism. The accuracy of cost estimation separates databases that perform well on varied workloads from those that don't.

← Back to the lexicon