Hello! + NestLoopState *nlstate = (NestLoopState *) child_node; + JoinType jointype = nlstate->js.jointype; + + if (jointype == JOIN_LEFT)
Isn't a `nlstate->js.ps.qual == NULL` missing from here? CREATE TABLE outer_t (id int, k int, payload text); CREATE TABLE inner_t (id int, fk int, val int); INSERT INTO outer_t SELECT g, g, 'row_' || g FROM generate_series(1, 200) g; INSERT INTO inner_t SELECT g, g, g FROM generate_series(1, 200) g; SET enable_hashjoin = off; SET enable_mergejoin = off; SET enable_material = off; SELECT o.id, i.val FROM outer_t o LEFT JOIN inner_t i ON o.k = i.fk WHERE (i.val IS NULL OR i.val > 50) ORDER BY o.id LIMIT 10; + else if (jointype == JOIN_RIGHT) + ExecSetTupleBound(tuples_needed, innerPlanState(child_node)); Is this branch reachable? If I follow the code correctly, it can't happen with create_nestloop_path. pg_plan_advice also has test failures with the patch applied.
