# Result Set Operations ![[assets/ex_join.png|256]] **Result Set Operations** are the **Interior Nodes** of the execution tree. They do not touch the disk; instead, they consume streams of tuples from the nodes below them and transform them into a final result. ### The Architectural Role This family represents the "Logic" of your SQL. These nodes are responsible for: 1. **Joins**: Correlating two streams of data (e.g., matching Animals to Species). 2. **Aggregations**: Reducing thousands of rows into a single summary (e.g., `COUNT(*)`, `SUM()`). 3. **Flow Control**: Sorting, limiting, and deduplicating data before it reaches the client. These operations are often the most CPU and RAM-intensive part of a query, frequently utilizing [[Manuscript/06 - Resource Management & Processes/6.3 - Work Mem (The Private Desk)|work_mem]] for in-memory processing. ### In the Explain Plan These nodes "wrap" the scan nodes below them. Their cost is cumulative—it includes the cost of all their children plus the cost of the transformation itself. ```text -> Hash Join (cost=10.45..45.67 rows=100 width=32) Hash Cond: (a.species_id = s.id) -> Seq Scan on animals a (...) -> Hash (...) -> Seq Scan on species s (...) ``` --- ![[Operations/ResultSet/Aggregate]] --- ![[Operations/ResultSet/Append]] --- ![[Operations/ResultSet/GatherMerge]] --- ![[Operations/ResultSet/Hash]] --- ![[Operations/ResultSet/HashJoin]] --- ![[Operations/ResultSet/Limit]] --- ![[Operations/ResultSet/Materialize]] --- ![[Operations/ResultSet/MergeAppend]] --- ![[Operations/ResultSet/MergeJoin]] --- ![[Operations/ResultSet/NestedLoop]] --- ![[Operations/ResultSet/ProjectSet]] --- ![[Operations/ResultSet/RecursiveUnion]] --- ![[Operations/ResultSet/SetOp]] --- ![[Operations/ResultSet/Sort]] --- ![[Operations/ResultSet/Unique]] --- ![[Operations/ResultSet/WindowAgg]]