IT lexicon › Database › Query planner

Query planner

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

The database engine component that determines the best execution strategy for a query based on data characteristics and available resources.

After an SQL query is parsed, the optimizer must choose among many possible execution paths. Should it scan an index or do a full table scan? Which join algorithm should it use and in what order should tables be joined? A rule-based optimizer followed fixed rules ("always use index if available"). A cost-based optimizer estimates the cost of each possible plan — in terms of disk accesses, memory requirements, or time — and picks the cheapest.

Cost-based optimization was first introduced in System R and Ingres in the 1970s-80s and became industry standard. It enabled database systems to automatically adapt to different data distributions — the same query might have different optimal strategies depending on which tables are large and which are small.

← Back to the lexicon