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

Chetan Mehrotra commented on OAK-2081:
--------------------------------------

bq. It looks like both indexes report the same "cost per entry" 
(IndexPlan.getCostPerEntry), but different estimated entry counts 
(IndexPlan.getEstimatedEntryCount). If a limit is used, then the query engine 
reduces the entry count. That sounds correct to me.

[~tmueller] Not sure on that. I think "limit" should not have influence on 
cost. Lets say index A has 10000 entries and index B has 50000 entries and 
limit is 100. Now the entries here are not matching entries but total number of 
indexed entries and many might be filtered out. So if both have same cost per 
entry then query engine should select #A as probability of finding matching 
first 100 entries faster is higher with #A (100 out of 10000) compared to #B 
(100 out of 50000). So "limit" should not influence the cost.

bq. If two indexes have different costs, then that should probably be reflected 
in the "cost per entry", or "cost per execution"

Not necessarily. Cost if function of "cost per entry",  "cost per execution" 
and "estimated entry count". Two indexes might have same "cost per entry",  
"cost per execution" but differ quite a bit in "estimated entry count". And in 
such a case index with lower  "estimated entry count" should be selected


> [Ordered Index] Incorrect index plan selection 
> -----------------------------------------------
>
>                 Key: OAK-2081
>                 URL: https://issues.apache.org/jira/browse/OAK-2081
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: query
>            Reporter: Amit Jain
>            Priority: Minor
>         Attachments: OAK-2081.patch
>
>
> When an ordered index is defined on multiple properties the plan selection 
> seems to be incorrect. There are a few potential problems :
> * For > or < conditions, the cost is doubled because of incorrect condition 
> in {{OrderedContentMirrorStoreStrategy#count}}. The condition should be 
> {{cost >= max}} instead of {{count > max}}
> * If multiple properties are specified in the index definition, only the 
> first property is indexed and others ignored. IMO only the first should be 
> used when selecting the plan in 
> {{OrderedPropertyIndexLookup#getIndexNode()}}, otherwise it may happen that 
> the property restriction that is not indexed is used for the index plan.
> * In {{QueryImpl#getBestSelectorExecutionPlan}} limit is used to damp the 
> cost which does not look right. E.g. limit is set to 10 and 2 plans with cost 
> 190 and 110 are candidates, the plan ultimately selected out of the 2 after 
> damping with the limit will be arbitrary (the first to be processed) as the 
> actual estimated cost is effectively ignored.



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

Reply via email to