> [!NOTE] Append > <table> > <tr> > <td width="25%"><img src="assets/ex_append.png"></td> > <td>Concatenates the results of multiple subqueries into a single output stream. It is the core mechanism behind <code>UNION ALL</code> and is also used to scan partitioned tables by appending the results of scanning each individual partition.</td> > </tr> > </table> > > ```sql > -- Combining two targeted lookups with UNION ALL > EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE) > SELECT * FROM animals WHERE id = 1 > UNION ALL > SELECT * FROM animals WHERE id = 2; > ``` > > ```text > Append (cost=1.29..16.62 rows=2 width=27) (actual time=1.005..1.012 rows=2 loops=1) > Buffers: shared hit=6 > -> Index Scan using animals_pkey on public.animals (...) > -> Index Scan using animals_pkey on public.animals animals_1 (...) > ``` > > <table> > <tr> > <td rowspan="5" width="25%"><img src="assets/ex_append.svg"></td> > <td><b>Performance</b></td><td>High performance; simply iterates through child nodes sequentially.</td> > </tr> > <tr><td><b>Factors</b></td><td>Number of subqueries and the combined overhead of their execution.</td></tr> > <tr><td><b>Cost</b></td><td><code>Sum of subquery costs.</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/IPC/Parallel/AppendReady">IPC: AppendReady</a>, <a href="Workloads/LWLock/Parallel/ParallelAppend">LWLock: ParallelAppend</a></td></tr> > <tr><td colspan="3"><b>Description</b>: Concatenates the results of subqueries.</td></tr> > </table>