Plan nodes · Set operations and appends

Recursive Union

Runs WITH RECURSIVE: the start query, then the recursive step until it returns nothing.

Runs the non-recursive part once, then repeatedly runs the recursive part over the rows of the previous round (read by a WorkTable Scan), until a round produces no rows.

Example

WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < 10) SELECT i FROM n

4 nodes

Run with EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) on the sample database, PostgreSQL 19.0. Open it in the EXPLAIN visualizer →

Related

Append · Merge Append · SetOp