*/
for (int i=0; i < optimizableList.size(); i++)
{
//Get one outer optimizable at a time from the join
//order
Optimizable considerOptimizable =
optimizableList.getOptimizable(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,
//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.