> [!NOTE] Operation Details > <table> > <tr> > <td width="25%"><img src="assets/ex_recursiveunion.png"></td> > <td>Orchestrates the execution of recursive Common Table Expressions.</td> > </tr> > </table> > > ```sql > -- Generating a sequence using a recursive CTE > EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE) > WITH RECURSIVE t(n) AS ( > VALUES (1) > UNION ALL > SELECT n+1 FROM t WHERE n < 10 > ) SELECT * FROM t; > ``` > > ```text > -> Recursive Union (cost=1.00..3.65 rows=31 width=4) (actual time=1.001..1.005 rows=10 loops=1) > -> Result (...) > -> WorkTable Scan on t t_1 (cost=1.00..1.23 rows=3 width=4) (actual time=1.000..1.000 rows=1 loops=10) > ``` > > <table> > <tr> > <td rowspan="5" width="25%"><img src="assets/ex_recursive_union.svg"></td> > <td><b>Performance</b></td><td>Efficiency depends on the recursion depth and the size of the "WorkTable" (the intermediate result set).</td> > </tr> > <tr><td><b>Factors</b></td><td>Recursion depth, memory available for the WorkTable, and the complexity of the recursive step.</td></tr> > <tr><td><b>Cost</b></td><td><code>iteration cost * number of iterations</code></td></tr> > <tr><td><b>Operates on</b></td><td><a href="Structures/Result Set">Result Set</a></td></tr> > <tr><td><b>Workloads</b></td><td><a href="Workloads/IO/BufFile/BufFileRead">IO: BufFileRead</a>, <a href="Workloads/IO/BufFile/BufFileWrite">IO: BufFileWrite</a>, <a href="Workloads/LWLock/Buffers/BufferContent">LWLock: BufferContent</a></td></tr> > <tr><td colspan="3"><b>Description</b>: Handles recursive CTEs.</td></tr> > </table>