Source:
<code>public void estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate innerCost) throws StandardException{ if(outerCost.isUninitialized() ||(outerCost.localCost()==0d && outerCost.getEstimatedRowCount()==1.0d)){ RowOrdering ro = outerCost.getRowOrdering(); if(ro!=null) outerCost.setRowOrdering(ro); return; } innerCost.setBase(innerCost.cloneMe()); double estimatedMemoryMB = innerCost.getEstimatedHeapSize()/1024d/1024d; double estimatedRowCount = innerCost.getEstimatedRowCount(); SConfiguration configuration=EngineDriver.driver().getConfiguration(); long regionThreshold = configuration.getBroadcastRegionMbThreshold(); long rowCountThreshold = configuration.getBroadcastRegionRowThreshold(); if (estimatedMemoryMB<regionThreshold && estimatedRowCount<rowCountThreshold) { double joinSelectivity = SelectivityUtil.estimateJoinSelectivity(innerTable, cd, predList, (long) innerCost.rowCount(), (long) outerCost.rowCount(), outerCost); double totalOutputRows = SelectivityUtil.getTotalRows(joinSelectivity, outerCost.rowCount(), innerCost.rowCount()); innerCost.setNumPartitions(outerCost.partitionCount()); double joinCost = SelectivityUtil.broadcastJoinStrategyLocalCost(innerCost, outerCost); innerCost.setLocalCost(joinCost); innerCost.setLocalCostPerPartition(joinCost); innerCost.setRemoteCost(SelectivityUtil.getTotalRemoteCost(innerCost, outerCost, totalOutputRows)); innerCost.setRowOrdering(outerCost.getRowOrdering()); innerCost.setRowCount(totalOutputRows); innerCost.setEstimatedHeapSize((long) SelectivityUtil.getTotalHeapSize(innerCost, outerCost, totalOutputRows)); } else { innerCost.setLocalCost(Double.MAX_VALUE); <START> innerCost.setRemoteCost(Double.MAX_VALUE); <END> } }</code><technical_language>if hint a Bcast rowCount is bigger threshold? setting cost MAX_VALUE screw rest of plan</technical_language>

Target:
public void estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate innerCost) throws StandardException{ if(outerCost.isUninitialized() ||(outerCost.localCost()==0d && outerCost.getEstimatedRowCount()==1.0d)){ RowOrdering ro = outerCost.getRowOrdering(); if(ro!=null) outerCost.setRowOrdering(ro); return; } innerCost.setBase(innerCost.cloneMe()); double estimatedMemoryMB = innerCost.getEstimatedHeapSize()/1024d/1024d; double estimatedRowCount = innerCost.getEstimatedRowCount(); SConfiguration configuration=EngineDriver.driver().getConfiguration(); long regionThreshold = configuration.getBroadcastRegionMbThreshold(); long rowCountThreshold = configuration.getBroadcastRegionRowThreshold(); AccessPath currentAccessPath = innerTable.getCurrentAccessPath(); boolean isHinted = currentAccessPath.isHintedJoinStrategy(); if (isHinted || estimatedMemoryMB<regionThreshold && estimatedRowCount<rowCountThreshold) { double joinSelectivity = SelectivityUtil.estimateJoinSelectivity(innerTable, cd, predList, (long) innerCost.rowCount(), (long) outerCost.rowCount(), outerCost); double totalOutputRows = SelectivityUtil.getTotalRows(joinSelectivity, outerCost.rowCount(), innerCost.rowCount()); innerCost.setNumPartitions(outerCost.partitionCount()); double joinCost = SelectivityUtil.broadcastJoinStrategyLocalCost(innerCost, outerCost); innerCost.setLocalCost(joinCost); innerCost.setLocalCostPerPartition(joinCost); innerCost.setRemoteCost(SelectivityUtil.getTotalRemoteCost(innerCost, outerCost, totalOutputRows)); innerCost.setRowOrdering(outerCost.getRowOrdering()); innerCost.setRowCount(totalOutputRows); innerCost.setEstimatedHeapSize((long) SelectivityUtil.getTotalHeapSize(innerCost, outerCost, totalOutputRows)); } else { innerCost.setLocalCost(Double.MAX_VALUE); innerCost.setRemoteCost(Double.MAX_VALUE); } }