liveBook · Manning

Query planner

A query planner is a database component that evaluates possible execution strategies and constructs or selects a plan for a query.

How 2 Manning books explain it

100 SQL Server Mistakes and How to Avoid Them

A query optimizer selects an efficient execution plan for a declarative database query.

How it is used
Determines efficient execution plans for declarative T-SQL and guides performance troubleshooting when selected plans are poor.
How deep it goes
Explains parsing, algebraization, metadata, costs, and physical joins, but does not detail the optimizer’s full algorithm.
Examples
Uses an impressions join, execution-plan figures, join hints, and indexes on join columns to illustrate plan selection.
What you can do after
Diagnose/debug with it by examining plans, questioning forced operators, and checking indexes and statistics before applying hints.

Read how 100 SQL Server Mistakes and How to Avoid Them explains query planner →

PostgreSQL Mistakes and How to Avoid Them

A query planner or optimizer is the database component that selects and may transform an execution strategy for a SQL query.

How it is used
Diagnoses SQL performance and explains why query structure, statistics, and configuration influence execution strategy.
How deep it goes
Explains cost-based plan selection, statistics, filter reordering, CTE inlining, and actual timing, but not detailed plan-node internals.
Examples
Uses unpaid-invoice email SQL, paired non-CTE and CTE queries, their plans, and EXPLAIN ANALYZE timing comparisons.
What you can do after
Diagnose/debug with EXPLAIN and EXPLAIN ANALYZE, then restructure SQL and maintain statistics to improve plan quality.

Read how PostgreSQL Mistakes and How to Avoid Them explains query planner →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.