query planner

/KWEER-ee PLAN-er/ · noun · Development · Origin: 1979

Definitions

  1. The database component that analyzes a SQL query and determines the most efficient execution strategy — which indexes to use, what join order and algorithms to apply, and whether to scan sequentially or seek by index. A good query planner is the difference between a query completing in milliseconds versus hours. PostgreSQL's planner uses cost-based optimization with table statistics.

    In plain English: The part of a database that figures out the fastest way to answer your question, like a GPS finding the best route through traffic.

    Example: EXPLAIN ANALYZE showed the query planner chose a sequential scan over the index because the table statistics were stale — running ANALYZE fixed it instantly.

Etymology

1970s
Early relational database prototypes at IBM (System R) developed cost-based query optimization, analyzing different execution strategies to find the most efficient plan.
1979
Pat Selinger published a landmark paper on System R's query optimizer, establishing cost-based planning with join ordering and access path selection as foundational techniques.
1990s
Commercial databases (Oracle, DB2, SQL Server) invested heavily in sophisticated query planners. EXPLAIN plans became an essential tool for database administrators tuning performance.
2010s-Present
PostgreSQL's query planner became renowned for its sophistication. Adaptive query execution, machine-learning-assisted planning, and real-time statistics improved planner decisions across modern databases.

Origin Story

The Invisible Strategist Behind Every Database Query

A query planner (also called a query optimizer) is the component of a database management system that decides the most efficient way to execute a given SQL statement. The concept traces back to IBM's System R project in the late 1970s, one of the first implementations of a relational database. Patricia Selinger and her colleagues published a foundational 1979 paper, 'Access Path Selection in a Relational Database Management System,' which laid out the cost-based optimization approach that remains the gold standard. Before query planners, programmers had to manually specify how data should be retrieved, choosing indexes and join orders by hand. Selinger's insight was that the database itself could estimate the cost of different execution strategies using statistics about table sizes, index availability, and data distribution, then automatically choose the cheapest plan. This abstraction freed developers to describe what data they wanted (declarative SQL) rather than how to get it. Every modern relational database, from PostgreSQL to Oracle, uses a descendant of this approach. The query planner is often the single most complex component in a database engine, silently making thousands of optimization decisions per second.

Coined by: Patricia Selinger and the IBM System R team

Context: Described in a landmark 1979 paper on cost-based access path selection in relational databases.

Fun fact: PostgreSQL's query planner can consider over a trillion possible join orderings for complex queries, but uses dynamic programming and heuristics to prune the search space down to a manageable size in milliseconds.

Related Terms