proposedJoinOrder[i] != -1; // -1: partial order
i++)
{
// Get one outer optimizable at a time from the join
// order
Optimizable considerOptimizable = optimizableList.
getOptimizable(proposedJoinOrder[i]);
// If we have come across the optimizable for the order
// by column in the join order, then we do not need to
// look at the inner optimizables in the join order. As
// long as the outer optimizables are one row
// resultset, or is ordered on the order by column (see
// below check), we are fine to consider sort
// avoidance.
if (considerOptimizable.getTableNumber() ==
cr.getTableNumber())
break;
/*
* The following if condition is checking if the
* outer optimizable to the order by column's
* optimizable is one row resultset or not.
*
* If the outer optimizable is one row resultset,
* then move on to the next optimizable in the join
* order and do the same check on that optimizable.
* Continue this until we are done checking that all
* the outer optimizables in the join order are single
* row resultsets. If we run into an outer optimizable
* which is not one row resultset, then we can not
* consider sort avoidance for the query.
*/
if (rowOrdering.alwaysOrdered(
considerOptimizable.getTableNumber()))
continue;
else
//This outer optimizable can return more than
//one row. Because of this, we can't avoid the
//sorting for this query.