Wiki / Plan Nodes / Combination
Merge Append
MergeAppend
Merges sorted child streams while preserving the required ordering.
Reading PostgreSQL 18.6.
Description
Merges sorted child streams while preserving the required ordering.
- Core node tag
- T_MergeAppend
- Structured EXPLAIN Node Type
- Merge Append
- Inputs
- Multiple sorted child plans
- Output
- Merged ordered tuples
- Executor initializer
- ExecInitMergeAppend
- Memory mechanism
- unclassified
EXPLAIN names and attributes
Structured formats use the Node Type above. Text-format spellings can also include operation, strategy, join type, scan direction or aggregation-stage attributes.
Text names recorded by this source: Merge Append.
Parallel-aware and parallel-safe are different plan properties. A node running inside a parallel worker is not necessarily a parallel-aware node.
Memory and temporary storage
This extraction does not assign a universal memory limit or spill policy to this node. Inspect the same-build implementation and its expressions or provider.
Parallel execution and instrumentation
The source callbacks below can coordinate execution or collect worker instrumentation. Their presence is not a blanket claim that this node supports a shared parallel scan or shared state.
Callbacks in this build: none extracted from this node implementation.
Executor implementation notes
NOTES A MergeAppend node contains a list of one or more subplans. These are each expected to deliver tuples that are sorted according to a common sort key. The MergeAppend node merges these streams to produce output sorted the same way.
MergeAppend nodes don't make use of their left and right subtrees, rather they maintain a list of subplans so a typical MergeAppend node looks like this in the plan tree:
... / MergeAppend---+------+------+--- nil / \ | | | nil nil ... ... ... subplans
We have one slot for each item in the heap array. We use SlotNumber to store slot indexes. This doesn't actually provide any formal type-safety, but it makes the code more self-documenting.
If run-time partition pruning is enabled, then set that up now
EXPLAIN identity in core source
case T_MergeAppend:
pname = sname = "Merge Append";
break;EXPLAIN labels in this source build
| Text-format label | Structured node identity |
|---|---|
| Merge Append | Merge Append |
Related entries
Documentation and source
- src/backend/commands/explain.c:1409
- src/backend/executor/execProcnode.c:186
- src/backend/executor/nodeMergeAppend.c
- src/include/nodes/plannodes.h
Source build
- Version
- 18.6
- Build
- PostgreSQL 18.6 source archive
- Source fingerprint
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f
Compare versions
PostgreSQL 17 → 18: unchanged.
Compares recorded interfaces and attributes. Source fingerprints and build metadata are excluded; an absent sample is not proof of the introduction or removal release.
Related entries
AppendAppendRecursive UnionRecursiveUnionSetOpSetOpUniqueUnique
Export JSON · Back to Plan Nodes · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.