瀏覽代碼

Merge pull request #5067 from ghalliday/issue9272

HPCC-9272 Add implicit CHOOSEN to filtered-index-read[n]

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 年之前
父節點
當前提交
7433f62464
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      ecl/hql/hqlopt.cpp

+ 13 - 0
ecl/hql/hqlopt.cpp

@@ -3778,6 +3778,19 @@ IHqlExpression * CTreeOptimizer::doCreateTransformed(IHqlExpression * transforme
                     }
                     break;
                 }
+            case no_compound_indexread:
+                {
+                    //If we reach here the index read isn't shared, so different indices won't duplicate the index read.
+                    if (!isLimitedDataset(child))
+                    {
+                        //Add a choosen() within the index read to minimize the records returned remotely - convert ir[1] to choosen(ir,1)[1]
+                        //Make it local because that is the thor semantics (roxie is happy with local or non local)
+                        OwnedHqlExpr limited = createDataset(no_choosen, LINK(child->queryChild(0)), createComma(LINK(transformed->queryChild(1)), createLocalAttribute()));
+                        OwnedHqlExpr newIndexRead = replaceChild(child, limited);
+                        return replaceChild(transformed, newIndexRead);
+                    }
+                    break;
+                }
             }
         }
     }