phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samarth Jain (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-1298) Queries on fixed width type columns that have an index declared on them don't use that index.
Date Fri, 26 Sep 2014 23:49:33 GMT

     [ https://issues.apache.org/jira/browse/PHOENIX-1298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Samarth Jain updated PHOENIX-1298:
----------------------------------
    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.

{code}

@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());
    }
 
{code}

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


  was:
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.

{code}

@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, v2)");
        PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
        String query = "select * from t where (v1, v2, k) > ('1', '2', '3')";
        QueryPlan plan = stmt.optimizeQuery(query);
        assertEquals("IDX", plan.getTableRef().getTable().getTableName().getString());
    }
    
 
{code}

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


        Summary: Queries on fixed width type columns that have an index declared on them don't
use that index.  (was: Queries on fixed width type columns that have an index declared on
them don't use that index with Row Value Constructors.)

> Queries on fixed width type columns that have an index declared on them don't use that
index.
> ---------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1298
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1298
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.0.0, 4.2, 3.2
>            Reporter: Samarth Jain
>
> 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.
> {code}
> @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());
>     }
>  
> {code}
> Instead of going through the index table, the query ends up using the data table.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message