Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 8b2ebe003 -> 52d3c7d01


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 52d3c7d015c0f929e97e1a50ab815d9570fcf248
Parents: 8b2ebe0
Author: maryannxue <maryann....@gmail.com>
Authored: Fri Apr 6 10:05:52 2018 -0700
Committer: maryannxue <maryann....@gmail.com>
Committed: Fri Apr 6 10:05:52 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/52d3c7d0/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