phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anoopsamj...@apache.org
Subject git commit: PHOENIX-933 Local index support to Phoenix. -Addendum2 (Rajesh)
Date Thu, 17 Jul 2014 05:35:50 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master a41dc5254 -> 60f262b3a


PHOENIX-933 Local index support to Phoenix. -Addendum2 (Rajesh)


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

Branch: refs/heads/master
Commit: 60f262b3af64f165d2f49ce67c2a79b1b2aee694
Parents: a41dc52
Author: anoopsjohn <anoopsamjohn@gmail.com>
Authored: Thu Jul 17 11:05:26 2014 +0530
Committer: anoopsjohn <anoopsamjohn@gmail.com>
Committed: Thu Jul 17 11:05:26 2014 +0530

----------------------------------------------------------------------
 .../java/org/apache/phoenix/optimize/QueryOptimizer.java  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/60f262b3/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 6537485..3b30989 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
@@ -297,10 +297,18 @@ public class QueryOptimizer {
                 // Account for potential view constants which are always bound
                 if (plan1 == dataPlan) { // plan2 is index plan. Ignore the viewIndexId if
present
                     c += boundRanges - (table2.getViewIndexId() == null || bothLocalIndexes
? 0 : 1);
+                    // if table2 is local index table and query doesn't have any condition
on the
+                    // indexed columns then give first priority to the local index.
                     if(table2.getIndexType()==IndexType.LOCAL && plan2.getContext().getScanRanges().getRanges().size()==0)
c++;
                 } else { // plan1 is index plan. Ignore the viewIndexId if present
                     c -= boundRanges - (table1.getViewIndexId() == null || bothLocalIndexes
? 0 : 1);
-                    if(table1.getIndexType()==IndexType.LOCAL && plan1.getContext().getScanRanges().getRanges().size()==0)
c++;
+                    // if table1 is local index table and query doesn't have any condition
on the
+                    // indexed columns then give first priority to the local index.
+                    if (!bothLocalIndexes && table1.getIndexType() == IndexType.LOCAL
+                            && plan1.getContext().getScanRanges().getRanges().isEmpty())
c--;
+                    // if both tables are index tables then select plan below based on number
of
+                    // columns and type of index.
+                    if(table1.getType()==PTableType.INDEX && table2.getType()==PTableType.INDEX
&& !bothLocalIndexes) c=0;
                 }
                 if (c != 0) return c;
                 if (plan1.getGroupBy()!=null && plan2.getGroupBy()!=null) {


Mime
View raw message