3. Query Processing
As noted in the official documentation, PostgreSQL supports a vast array of features mandated by the SQL:2011 standard. The query processing subsystem is the most complex component of PostgreSQL, designed to handle supported SQL statements efficiently.
This chapter outlines the query processing workflow, with a particular focus on query optimization.
-
Part 1: Overview (Section 3.1):
Provides an overview of the query processing workflow in PostgreSQL. -
Part 2: Single-Table Queries (Sections 3.2 — 3.4)
Explains the steps required to obtain the optimal plan for a single-table query. Sections 3.2 and 3.3 cover cost estimation and plan tree generation, respectively. Section 3.4 describes the operation of the executor. -
Part 3: Multiple-Table Queries (Sections 3.5 — 3.6)
Covers the process of determining the optimal plan for multiple-table queries. Section 3.5 describes three join methods—nested loop, merge, and hash join — while Section 3.6 explains how the plan tree for multiple-table queries is constructed. -
Part 4: Parallel Query (Section 3.7)
Explains Parallel Query feature.
PostgreSQL also supports two technically advanced and practical features: Foreign Data Wrappers (FDW) and JIT compilation (introduced in version 11).
The FDW is covered in Chapter 4, while JIT compilation is outside the scope of this documentation.