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

Lars Hofhansl commented on PHOENIX-4964:
----------------------------------------

Here's a better patch.

.v2 uses a local index anyway, if it allowed us to optimize the ORDER BY away. 
This will be almost always the right thing to do.

I'll look into global indexes next or perhaps file a separate issue (as global 
uncovered indexes are not generally as useful).

> ORDER BY does not use an index if the query is not fully covered
> ----------------------------------------------------------------
>
>                 Key: PHOENIX-4964
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4964
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Lars Hofhansl
>            Priority: Minor
>         Attachments: PHOENIX-4964-4.x-HBase-1.4.txt, 
> PHOENIX-4964-4.x-HBase-1.4.v2.txt
>
>
> I just noticed that a query like
> {{SELECT <column1> FROM <table> ORDER BY <column2> LIMIT <n>}}
> Does not use an index on <column2> if it does not also include <column1>. 
> That seems too limited.
> I can see the code in QueryOptimizer.addPlan that rewrites the plan only when 
> there's a WHERE clause, and then only for the WHERE clause. 



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

Reply via email to