# `HashJoin` Execution Plan

```7
tidb> EXPLAIN SELECT * FROM db1.employees, db1.salaries WHERE db1.employees.emp_no = db1.salaries.emp_no;
+-------------------------+------------+-----------+-----------------+-------------------------------------------------------------------+
| id                      | estRows    | task      | access object   | operator info                                                     |
+-------------------------+------------+-----------+-----------------+-------------------------------------------------------------------+
| ~!@HashJoin_9@!~              | 2825288.58 | root      |                 | inner join, equal:[eq(db1.employees.emp_no, db1.salaries.emp_no)] |
| ├─~!@TableReader_11(Build)@!~ | 300024.00  | root      |                 | data:TableFullScan_10                                             |
| │ └─TableFullScan_10    | 300024.00  | cop[tikv] | table:employees | keep order:false                                                  |
| └─~!@TableReader_13(Probe)@!~ | 2844047.00 | root      |                 | data:TableFullScan_12                                             |
|  └─TableFullScan_12     | 2844047.00 | cop[tikv] | table:salaries  | keep order:false                                                  |
+-------------------------+------------+-----------+-----------------+-------------------------------------------------------------------+
5 rows in set (0.01 sec)
```

------------------------------------------------------------------------------
Reviewing the execution plan, the `TableFullScan_10` operation on line 3 is executed before the `TableReader_11 (Build)` operation. This step performs a full table scan on the `employees` table, storing the results in the TiDB Server cache. Following this, the `TableFullScan_12` on line 5 scans the `salaries` table, with the rows retrieved being matched against the cached `employees` table. The final join operation, `HashJoin_9`, is completed on line 1.

The `Build` flag on `TableReader_11 (Build)` and the `Probe` flag on `TableReader_13 (Probe)` indicate that `TableReader_11 (Build)` should be executed before `TableReader_13 (Probe)`.

Characteristics of the `HashJoin` operation:
- Scanning of the driving table is done in the cache using a hash index, allowing for parallel processing and improved performance.
- The driving table needs to be fully scanned and cached, so it should be of manageable size to avoid performance issues.