> [!NOTE] Hash
> <table>
> <tr>
> <td width="25%"><img src="assets/ex_hash.png"></td>
> <td>A preparatory node for Hash Joins. It reads the inner relation and organizes its rows into a hash table based on the join key. The size of this hash table is constrained by <code>work_mem</code>; exceeding it causes the table to be partitioned into multiple 'batches'.</td>
> </tr>
> </table>
>
> ```sql
> -- Building a hash table for a Join
> EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE)
> SELECT * FROM animals a
> JOIN species s ON a.species_id = s.id;
> ```
>
> ```text
> -> Hash (cost=2.05..2.05 rows=5 width=15) (actual time=1.341..1.341 rows=5 loops=1)
> Output: s.id, s.name, s.diet_type
> Buckets: 1024 Batches: 1 Memory Usage: 9kB
> Buffers: shared read=1
> -> Seq Scan on public.species s (...)
> ```
>
> <table>
> <tr>
> <td rowspan="5" width="25%"><img src="assets/ex_hash.svg"></td>
> <td><b>Performance</b></td><td>High performance for large equality joins; memory-intensive as it stores the entire inner relation in <code>work_mem</code>.</td>
> </tr>
> <tr><td><b>Factors</b></td><td>Size of the inner relation, available <code>work_mem</code>, and hash collision rates.</td></tr>
> <tr><td><b>Cost</b></td><td><code>cpu_operator_cost * number of tuples</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/Parallel/ParallelHashJoin">LWLock: ParallelHashJoin</a>, <a href="Workloads/IPC/Hash/HashBuildAllocate">IPC: HashBuildAllocate</a>, <a href="Workloads/IPC/Hash/HashBuildElect">IPC: HashBuildElect</a>, <a href="Workloads/IPC/Hash/HashGrowBatchesElect">IPC: HashGrowBatchesElect</a>, <a href="Workloads/IPC/Hash/HashGrowBucketsElect">IPC: HashGrowBucketsElect</a></td></tr>
> <tr><td colspan="3"><b>Description</b>: Builds an in-memory hash table from the inner relation of a join.</td></tr>
> </table>