# `IndexJoin` and `IndexHashJoin` Process

+ `IndexHashJoin` creates a hash table for the driving table. 
  + This can be more memory-efficient in some scenarios.

![`smart`](IndexJoin02_aa_002_20230913.png)

------------------------------------------------------------------------------
In the slide, a row from the `employees` table is read and its `emp_no` value is matched with the `emp_no` column in the `salaries` table. Since the `salaries` table has an index on the `emp_no` column, an `IndexRangeScan` is used for matching. If the index has high selectivity (many distinct values), the complexity of the `IndexJoin` or `IndexHashJoin` is roughly the sum of the number of rows in both tables. Unlike `MergeJoin` and `HashJoin`, the `IndexJoin` or `IndexHashJoin` does not require as much data to be cached in memory.

The `IndexHashJoin` and `IndexJoin` processes are similar, with the key difference being that `IndexHashJoin` creates a hash table for the driving table. This can be more memory-efficient in some scenarios.

However, an issue arises when each row from the driving table (`employees`) requires an index scan on the driven table (`salaries`), which can reduce efficiency. Improvements to this approach are discussed in the following slides.