Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 d147d8f06 -> 1b7f58104


PHOENIX-4616 Move join query optimization out from QueryCompiler into 
QueryOptimizer (addendum)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1b7f5810
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1b7f5810
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1b7f5810

Branch: refs/heads/4.x-HBase-1.1
Commit: 1b7f58104b033e613e1ca939aa53ae11f6b43385
Parents: d147d8f
Author: maryannxue <maryann....@gmail.com>
Authored: Fri Apr 6 13:58:15 2018 -0700
Committer: maryannxue <maryann....@gmail.com>
Committed: Fri Apr 6 13:58:15 2018 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/optimize/QueryOptimizer.java     | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1b7f5810/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index 31f5c34..6d668cc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -38,7 +38,6 @@ import org.apache.phoenix.compile.SequenceManager;
 import org.apache.phoenix.compile.StatementContext;
 import org.apache.phoenix.compile.StatementNormalizer;
 import org.apache.phoenix.compile.SubqueryRewriter;
-import org.apache.phoenix.execute.BaseQueryPlan;
 import org.apache.phoenix.iterate.ParallelIteratorFactory;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixStatement;
@@ -126,11 +125,14 @@ public class QueryOptimizer {
             return Collections.singletonList(dataPlan);
         }
 
-        if (dataPlan instanceof BaseQueryPlan) {
-            return getApplicablePlans((BaseQueryPlan) dataPlan, statement, 
targetColumns, parallelIteratorFactory, stopAtBestPlan);
+        SelectStatement select = (SelectStatement) dataPlan.getStatement();
+        if (!select.isUnion()
+                && !select.isJoin()
+                && select.getInnerSelectStatement() == null
+                && (select.getWhere() == null || 
!select.getWhere().hasSubquery())) {
+            return getApplicablePlansForSingleFlatQuery(dataPlan, statement, 
targetColumns, parallelIteratorFactory, stopAtBestPlan);
         }
 
-        SelectStatement select = (SelectStatement) dataPlan.getStatement();
         ColumnResolver resolver = FromCompiler.getResolverForQuery(select, 
statement.getConnection());
         Map<TableRef, QueryPlan> dataPlans = null;
 
@@ -187,7 +189,7 @@ public class QueryOptimizer {
         return Collections.singletonList(compiler.compile());
     }
 
-    private List<QueryPlan> getApplicablePlans(BaseQueryPlan dataPlan, 
PhoenixStatement statement, List<? extends PDatum> targetColumns, 
ParallelIteratorFactory parallelIteratorFactory, boolean stopAtBestPlan) throws 
SQLException {
+    private List<QueryPlan> getApplicablePlansForSingleFlatQuery(QueryPlan 
dataPlan, PhoenixStatement statement, List<? extends PDatum> targetColumns, 
ParallelIteratorFactory parallelIteratorFactory, boolean stopAtBestPlan) throws 
SQLException {
         SelectStatement select = (SelectStatement)dataPlan.getStatement();
         // Exit early if we have a point lookup as we can't get better than 
that
         if (dataPlan.getContext().getScanRanges().isPointLookup() && 
stopAtBestPlan) {

Reply via email to