@Override public RelOptCost computeSelfCost(RelOptPlanner planner) { // Higher cost if rows are wider discourages pushing a project through a // sort. double rowCount = RelMetadataQuery.getRowCount(this); double bytesPerRow = getRowType().getFieldCount() * 4; return planner.getCostFactory().makeCost(Util.nLogN(rowCount) * bytesPerRow, rowCount, 0); }