One session executes the same join SELECT in captured nested-loop and hash-join variants.
MySQL Join Algorithms
Plan, row flow, and evidence for Indexed Nested Loop and Hash JoinQuestion for this Lab
To produce the same join result, which input does nested-loop revisit and which inputs does hash join build and probe?
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';
Index availability, operator structure, outer and inner repetition, hash build/probe stages, and related statement counters change.
The join predicate, matched result rows, and checksum stay identical across both algorithm variants.
Which two roles should you trace in the hash-join variant?
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?
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
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.
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.
SQL shared by both variants
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';