Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-1298

Queries on fixed width type columns that have an index declared on them don't use that index

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.2.0, 3.2.0
    • 4.2.0, 3.2.0
    • None
    • None

    Description

      Happens when the index is on a column whose data type is fixed width. If V1 is made of type VARCHAR, then the test passes.

      @Test
      
          public void testRVCUsingPkColsReturnedByPlanShouldUseIndex() throws Exception {
              Connection conn = DriverManager.getConnection(getUrl());
              conn.createStatement().execute("CREATE TABLE T (k VARCHAR NOT NULL PRIMARY KEY, v1 CHAR(15), v2 VARCHAR)");
              conn.createStatement().execute("CREATE INDEX IDX ON T(v1)");
              PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
              String query = "select * from t where v1 = '1'";
              QueryPlan plan = stmt.optimizeQuery(query);
              assertEquals("IDX", plan.getTableRef().getTable().getTableName().getString());
          }
       
      

      Instead of going through the index table, the query ends up using the data table.

      Attachments

        1. PHOENIX-1298.patch
          3 kB
          James R. Taylor
        2. PHOENIX-1298.patch
          3 kB
          James R. Taylor

        Activity

          People

            samarthjain Samarth Jain
            samarthjain Samarth Jain
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: