And they are not. Here is the code
    public CompiledPlan compilePlan(..) {

        ..............
        if (parsedStmt instanceof ParsedUnionStmt) {

           .........
           // this is the loop over the union's selects
            for (AbstractParsedStmt parsedChildStmt :
parsedUnionStmt.m_children) {
                CompiledPlan bestChildPlan =
getBestCostPlan(parsedChildStmt, costModel,
                        sql, joinOrder, stmtName, procName, paramHints,
isPlanFinal);
                // make sure we got a winner
                if (bestChildPlan == null) {
                    m_recentErrorMsg = "Unable to plan for statement. Error
unknown.";
                    return null;
                }
                childrenPlans.add(bestChildPlan);
                orderIsDeterministic = orderIsDeterministic &&
bestChildPlan.isOrderDeterministic();
                contentIsDeterministic = contentIsDeterministic &&
bestChildPlan.isContentDeterministic();
            }   // end of the loop
            ....................
        } else {  //  Select statement
            boolean isPlanFinal = true;
            bestPlan = getBestCostPlan(parsedStmt, costModel,
                    sql, joinOrder, stmtName,procName, paramHints,
isPlanFinal);
        }
       ........

        // reset all the plan node ids for a given plan
        // this makes the ids deterministic
        bestPlan.resetPlanNodeIds();

        // split up the plan everywhere we see send/recieve into multiple
plan fragments
        Fragmentizer.fragmentize(bestPlan, m_db);
        return bestPlan;


}

resetPlanNodeIds and Fragmentizer.fragmentize are called at the very end of
the compilePlan method which is not in the loop at all. The loop over the
union's selects are at the lines 160-171

           for (AbstractParsedStmt parsedChildStmt :
parsedUnionStmt.m_children) {
                CompiledPlan bestChildPlan =
getBestCostPlan(parsedChildStmt, costModel,
                        sql, joinOrder, stmtName, procName, paramHints,
isPlanFinal);
                // make sure we got a winner
                if (bestChildPlan == null) {
                    m_recentErrorMsg = "Unable to plan for statement. Error
unknown.";
                    return null;
                }
                childrenPlans.add(bestChildPlan);
                orderIsDeterministic = orderIsDeterministic &&
bestChildPlan.isOrderDeterministic();
                contentIsDeterministic = contentIsDeterministic &&
bestChildPlan.isContentDeterministic();
            }

The only method which is called multiple times (once per select) is
getBestCostPlan




On Mon, Sep 24, 2012 at 10:54 AM, Paul A Martel <notifications@github.com>wrote:

> In src/frontend/org/voltdb/planner/QueryPlanner.java:
>
> > @@ -368,23 +456,10 @@ private CompiledPlan compileFromXML(VoltXMLElement xmlSQL) {
> >              }
> >          }
> >
> > -        // make sure we got a winner
> > -        if (bestPlan == null) {
> > -            m_recentErrorMsg = "Unable to plan for statement. Error unknown.";
> > -            return null;
> > -        }
> > -
> > -        // reset all the plan node ids for a given plan
> > -        // this makes the ids deterministic
> > -        bestPlan.resetPlanNodeIds();
>
> What I am trying to say is that resetPlanNodeIds and
> Fragmentizer.fragmentize should only need to be called on the final plan
> (whether that is a union or a select).
> They should not be called inside the loop (where it would also get applied
> to a union's non-final select plan children).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/alexeevm/voltdb/pull/3/files#r1673775>.
>
>