Engine Atlas

MySQL Join Algorithms

Plan, row flow, and evidence for Indexed Nested Loop and Hash Join
MySQL 8.4.10captured
한국어
Learning guide

Question for this Lab

To produce the same join result, which input does nested-loop revisit and which inputs does hash join build and probe?

Execution engine: MySQL 8.4.10
Who runs it?

One session executes the same join SELECT in captured nested-loop and hash-join variants.

What stays controlled?

The same two input tables, SQL, returned rows, and checksum stay fixed, while only the indexed variant has idx_join_orders_customer_status in its capture condition.

Executed SQL
SELECT
  c.id AS customer_id,
  c.segment,
  o.id AS order_id,
  o.status,
  o.total_cents
FROM join_customers AS c
JOIN join_orders AS o
  ON o.customer_code = c.customer_code
WHERE c.region_code = 'KR'
  AND o.status = 'PAID';
What changes?

Index availability, operator structure, outer and inner repetition, hash build/probe stages, and related statement counters change.

What stays fixed?

The join predicate, matched result rows, and checksum stay identical across both algorithm variants.

Predict before tracing

Which two roles should you trace in the hash-join variant?

Which two roles should you trace in the hash-join variant?

Evidence mission

Open the match-flow step of the hash-join variant and identify which input builds and which input probes.

Where do you look?
Read the build-side and probe-side markers in the join lens together with the Hash and Inner hash join operators in the plan.
Screen to open
Hash Join · match flow
What should you see?
Expected observation

The hash-join capture has a Hash operator as a direct child of the join and no index-lookup operator. idx_join_orders_customer_status exists only in the indexed-nested-loop capture condition, and both variants record 257 join output rows.

Evidence boundary
Captured
hash-join plan shape with its Hash child and Inner hash join operator, plus the 257 parent join output rows
Derived · fixture
JOIN_PAIRS membership matched on customer_code
Checkpoint · explain from evidenceCan the captured completion time from these two variants prove that one algorithm is generally superior?Reveal answer and basis

No. The capture is execution evidence for this fixture and server state. It explains algorithm structure and row flow but cannot establish a universal performance ranking.

Evidence boundary
Captured
plan shape, row flow, counters, and completion time
Core takeaway

Read a join comparison through the input that repeats, builds, or probes and through how the same result is assembled, not through the algorithm name alone.

Next connection

The next Lab follows intermediate rows from a join or aggregation into internal temporary-table and sort storage.

Review terms
nested-loop joinIntroduced in Lab 04
A join execution method that searches the inner input for matches for each row from the outer input.
hash build / probeIntroduced in Lab 04
The two phases that build a hash table from one join input and probe it with keys from the other input.

01 · SOURCE

SQL shared by both variants

1 active fragmentMySQLJOIN · no ORDER BY
SELECT c.id AS customer_id, c.segment, o.id AS order_id, o.status, o.total_cents
FROM join_customers AS c
JOIN join_orders AS o ON o.customer_code = c.customer_code
WHERE c.region_code = 'KR'
  AND o.status = 'PAID';
02 · FLOW

Native plan and actual iterators

01 / 12
01/ 12