phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/2] phoenix git commit: PHOENIX-1436 the choice of index by phoneix is not correct where do querying
Date Sat, 22 Nov 2014 05:19:58 GMT
Repository: phoenix
Updated Branches:
  refs/heads/3.2 7f52d2789 -> 0669b66e4


PHOENIX-1436 the choice of index by phoneix is not correct where do querying

Conflicts:
	phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java


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

Branch: refs/heads/3.2
Commit: 3791c495fd8fed935b21462bfaf61a8c8e5fd9a0
Parents: 7f52d27
Author: James Taylor <jtaylor@salesforce.com>
Authored: Fri Nov 21 21:08:37 2014 -0800
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Fri Nov 21 21:18:57 2014 -0800

----------------------------------------------------------------------
 .../apache/phoenix/compile/QueryOptimizerTest.java   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3791c495/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
index c046bc6..c45d75c 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java
@@ -25,6 +25,7 @@ import java.sql.Connection;
 import java.sql.Date;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
@@ -38,6 +39,7 @@ import org.apache.phoenix.query.BaseConnectionlessQueryTest;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.schema.PTableType;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.SchemaUtil;
 import org.junit.Test;
 
@@ -370,6 +372,19 @@ public class QueryOptimizerTest extends BaseConnectionlessQueryTest {
         testAssertQueryPlanDetails(false, true, false);
     }
 
+    @Test
+    public void testQueryOptimizerShouldSelectThePlanWithMoreNumberOfPKColumns() throws Exception
{
+        Connection conn1 = DriverManager.getConnection(getUrl());
+        Connection conn2 = DriverManager.getConnection(getUrl());
+        conn1.createStatement().execute("create table index_test_table (a varchar not null,b
varchar not null,c varchar not null,d varchar,e varchar, f varchar constraint pk primary key(a,b,c))");
+        conn1.createStatement().execute(
+            "create index INDEX_TEST_TABLE_INDEX_D on INDEX_TEST_TABLE(A,D) include(B,C,E,F)");
+        conn1.createStatement().execute(
+            "create index INDEX_TEST_TABLE_INDEX_F on INDEX_TEST_TABLE(A,F) include(B,C,D,E)");
+        ResultSet rs = conn2.createStatement().executeQuery("explain select * from INDEX_TEST_TABLE
where A in ('1','2','3','4','5') and F in ('1111','2222','3333')");
+        assertEquals("CLIENT PARALLEL 1-WAY SKIP SCAN ON 15 KEYS OVER INDEX_TEST_TABLE_INDEX_F
['1','1111'] - ['5','3333']", QueryUtil.getExplainPlan(rs));
+    }
+
     private void testAssertQueryPlanDetails(boolean multitenant, boolean useIndex, boolean
salted) throws Exception {
         String sql;
         PreparedStatement stmt;


Mime
View raw message