Query Optimizer
A database component that evaluates access paths and join orders and selects an execution plan using statistics and a cost model.
The query optimizer translates what a SQL statement requests into a physical execution strategy. Candidate index scans, full scans, join methods, and join orders are compared using cardinality estimates and a cost model for CPU, I/O, and memory.
A poor plan is often preceded by a poor estimate rather than a mysterious optimizer failure. Histograms, bind-value distribution, correlated columns, and stale statistics can all distort cardinality. Plan diagnosis should therefore compare estimated and actual row counts at each stage instead of looking only at the final access path.
Related: Execution Plan, Cardinality Estimation, Index Selectivity, Oracle Database and PL/SQL, Engineering Meaning of Indexes in Relational Databases.