Naive Hash Join

Naive Hash Join

Naive Hash Join performs an in-memory hash table build and then join.

Prerequisite: Relation can fit into memory (that is, having ). And this often not going to be possible, so solution is Grace Hash Join.

It’s basic idea is that we read all pages of relation , building an in-memory hash table, and then read in each records of to look it up in table.

Link to original

Grace Hash Join

Grace Hash Join

  • Partitioning phase: We try to split R and S into partitions. Each partition has and (i.e. partition i of and partition i of ) and make sure either or pages. If not, recursively do partition.
    • Make sure records with same hash value are in the same partition.
  • Build & Probe Phase: Load the smaller partition into memory and build an in-memory hash table. Perform a Naive Hash Join with the larger partition in the pair.

I/O COST:

  • First phase: read + write both relations
    • I/Os
  • Second phase: read both relations, forward output
    • I/Os
  • Total cost of 2-pass hash join =
Link to original