Query optimizer
An automated engine that determines the most efficient execution path for a SQL query.
The query optimizer analyzes an SQL statement, enumerates possible execution plans, and selects the one with the lowest estimated cost. It consults database statistics about table sizes and selectivity to estimate row counts at each step. The optimizer chooses among different index structures, locking strategies, and join algorithms.
Without a query optimizer, users would have to hand-write optimal SQL — impossible as data volumes grow. Since the 1970s, the optimizer has been the heart of relational databases, from Ingres and Sybase to PostgreSQL and MySQL today.