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

Lars Hofhansl commented on PHOENIX-5096:
----------------------------------------

What also works:
create table test (pk1 integer not null, pk2 integer not null, pk3 integer not 
null, v1 float, v2 float, v3 integer CONSTRAINT pk *PRIMARY KEY (pk1, pk2, 
pk3)*);
create local index l1 on *test(pk1, v1)*;

{code}
0: jdbc:phoenix:localhost> explain select /* NO_INDEX */ count(*) from test 
where pk1 < 1 and pk1 >= 0 and v1 < 0.001;
+------------------------------------------------------------------------------------------------------------------+-----------------+----------------+----------------+
|                                                       PLAN                    
                                   | EST_BYTES_READ  | EST_ROWS_READ  |  
EST_INFO_TS   |
+------------------------------------------------------------------------------------------------------------------+-----------------+----------------+----------------+
| CLIENT 1-CHUNK 5518821 ROWS 314572800 BYTES PARALLEL 1-WAY SKIP SCAN ON 1 
RANGE OVER TEST [1,0,*] - [1,1,0.001]  | 314572800       | 5518821        | 
1547163312051  |
|     SERVER FILTER BY FIRST KEY ONLY                                           
                                   | 314572800       | 5518821        | 
1547163312051  |
|     SERVER AGGREGATE INTO SINGLE ROW                                          
                                   | 314572800       | 5518821        | 
1547163312051  |
+------------------------------------------------------------------------------------------------------------------+-----------------+----------------+----------------+
3 rows selected (0.054 seconds)
{code}

So if the pk part if completely bound it work... Again only when we rearrange 
the key structure of the local index.

> Local index region pruning is not working as expected.
> ------------------------------------------------------
>
>                 Key: PHOENIX-5096
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5096
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>            Priority: Major
>
> The pruning of local indexes should do the following:
> * Use the local index
> * Reduce the number of regions based on filters on the table's primary key 
> (i.e. WHERE conditions including prefixes of the primary key)
> Instead it looks like in order for this to work the needed PK column need to 
> be included in the local index itself, changing the sort order of the local 
> index.
> I'll provide some examples in the comments.
> [~giacomotaylor], [~tdsilva], [~vincentpoon], [~elserj], [~gjacoby]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to