Plan Trees
Same Result, Different Plan
Nested-loop and hash plans can produce identical row sets.
Same result, different mechanism
Two physical plans can produce the same query result. This lesson renders both mechanisms and compares only recomputed outputs. Note: plan choice changes mechanism, not result rows.
Nested-loop plan
The nested-loop plan recomputes row count 2. Note: the result rows are shown only in the rendered table.
cardinalities are exact counts on these tiny tables; choosing a plan by cost needs statistics and is deferred - no speed/perf claims; nested-loop vs hash is mechanism, not speed.
Hash plan
The hash plan recomputes row count 2. Note: the render has the same result rows by recompute, not by prose assertion.
cardinalities are exact counts on these tiny tables; choosing a plan by cost needs statistics and is deferred - no speed/perf claims; nested-loop vs hash is mechanism, not speed.
Side by side
Both root counts are 2. Note: equality means identical row sets for this tiny query.
cardinalities are exact counts on these tiny tables; choosing a plan by cost needs statistics and is deferred - no speed/perf claims; nested-loop vs hash is mechanism, not speed.
Summary
Nested-loop and hash plans can be equivalent mechanisms for one query result. Note: choosing by cost needs statistics and is deferred.