Apex › Storage & databases

How to join tables bigger than RAM (grace hash join)

An in-memory hash join needs one table to fit in RAM. When both are far bigger, the grace hash join first partitions BOTH tables by hash(join key) into buckets — so matching keys always land in the same partition pair — spilling them to disk, then joins each small partition-pair in memory (build a hash table on R_i, probe with S_i). Verified in node: the output equals a nested-loop join exactly over 400 random joins, in O(|R|+|S|) I/O rather than O(|R|·|S|). Step through the partition and join phases.

More in Storage & databases