# Join Technology (A)

+ `Hash Join`:
  + The driving table is read into the**hash** table constructed by TiDB at a time, and the matched data is return by comparing the driving table data with the**hash** table.
  + Multi-threaded concurrent operation, which is faster and consumes memory. It is suitable for scenario with high execution time requirements and large memory.

------------------------------------------------------------

The join algorithms selected in the execution plan in this case are Hash Join and Index Hash Join. Here, we also briefly introduce the implementation mechanism and applicable scenario of the join algorithm in TiDB. There are four types of join algorithms:
- Hash Join
  - Do not require an orderly join column, read the driving table to TIDB once to construct a hash table, and then compare the driving table data with the hash table to return the matching data.
  - Multi-threaded concurrent operation, which is fast and consumes memory. It is suitable for scenario with high execution time requirements and large memory.
- Merge Join
  - The join column needs to be ordered (indexed or sort data), read the driving table ordered table data in batches and return after matching the driving table ordered table data
  - There is no concurrency, takes up less memory, and the execution practice is generally longer than Hash Join. It is suitable for scenario with large tables and small memory that do not require high execution time.
- Index Join (Index Nested Loop Join)
  - The join column needs to be ordered (indexed or sort data), and the query range of the driven table is constructed in parallel according to the ordered data of the driving table, and then matched with the batch-driven driving table data
  - Multi-threaded concurrency, suitable for scenario the driving table result set is small (about 1w row)
- Index Hash Join (Index Nested Loop Hash Join)
  - The algorithm uses exactly the same conditions as Index Join, but it saves more memory resources in some scenario
