Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 fe03c3006 -> 6521c87a0


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/6521c87a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6521c87a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6521c87a

Branch: refs/heads/5.x-HBase-2.0
Commit: 6521c87a03c001908f0d4fabf0f968e72c2d0a89
Parents: fe03c30
Author: maryannxue <maryann....@gmail.com>
Authored: Fri Apr 6 14:04:02 2018 -0700
Committer: maryannxue <maryann....@gmail.com>
Committed: Fri Apr 6 14:04:02 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/6521c87a/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 44baee4..4f2a5e9 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;
@@ -123,11 +122,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;
 
@@ -184,7 +186,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