Query planner
A query planner is a database component that evaluates possible execution strategies and constructs or selects a plan for a query.
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
- execution planproduces · An execution plan is a structured description of the operations or tasks arranged to carry out a query or other task.
- indexinguses · Indexing is the organization or use of positions, keys, or lookup structures to identify and retrieve selected data or elements.
- statisticsuses · Statistics is the discipline and set of methods for collecting, summarizing, analyzing, and interpreting data, including numerical descriptions used to characterize observations and support inference.
- hidden indexcontrasts with · A hidden index is an index configured to be omitted from certain ordinary discovery, listing, planning, or selection operations.
- composite indexuses · A composite index is a database index whose key contains multiple fields or columns, ordered according to the index definition.
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.

