[ 
https://issues.apache.org/jira/browse/PHOENIX-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14277365#comment-14277365
 ] 

James Taylor commented on PHOENIX-1560:
---------------------------------------

One other small issue in the way you're constructing the RVC for the subquery: 
- you'll need to skip more than just the salt column under some circumstances. 
If the connection is a tenant-specific connection and the table is 
multi-tenant, then you'll need to skip the next column (the tenant id column) 
as well. In this case, the tenant ID column is not accessible and you'd get an 
error if you referred to it:
{code}
                boolean isSalted = table.getBucketNum() != null;
                isTenantSpecific = table.isMultiTenant() && 
connection.getTenantId() != null;
                int posOffset = (isSalted ? 1 : 0) + (isTenantSpecific ? 1 : 0);
                for (int i = posOffset : i < pkColumns.size(); i++) {
                    PColumn column = pkColumns.get(i);
{code}
- If the index being joined to is a "shared" index (i.e. the index table 
contains index data for more than a single table which is the case for an index 
on a view and a local index), then the PK of the index table also contains an 
index ID. If all works as expected, a condition will be added by the 
WhereOptimizer for this when your subquery is compiled, but it'd be good to 
have a test around this. See ViewIT.testViewUsesTableIndex(), as you could 
likely add a test with an index hint there that'll cover testing this.

> Join between global index and data table if INDEX hint used
> -----------------------------------------------------------
>
>                 Key: PHOENIX-1560
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1560
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Maryann Xue
>         Attachments: 1560.patch
>
>
> We already have an INDEX hint, and we already have a mechanism to collect 
> referenced columns in the data table that are not in the index table (used 
> only for local indexes currently). Instead of not using the global index when 
> a referenced data column is not found in the index, we should rewrite the 
> query to join back to the data table when the INDEX hint is present. This is 
> always possible, as we always have the data PK columns in the index table, 
> and our join optimization would kick in as well.



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

Reply via email to