You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2015/10/08 16:43:59 UTC
svn commit: r1707553 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak:
plugins/index/nodetype/NodeTypeIndexLookup.java query/QueryImpl.java
Author: thomasm
Date: Thu Oct 8 14:43:58 2015
New Revision: 1707553
URL: http://svn.apache.org/viewvc?rev=1707553&view=rev
Log:
OAK-3480 Query engine: faster cost calculation (take 2)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java?rev=1707553&r1=1707552&r2=1707553&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexLookup.java Thu Oct 8 14:43:58 2015
@@ -34,7 +34,7 @@ class NodeTypeIndexLookup implements Jcr
/**
* Derived from {@link #getCost(Filter)}
*/
- static final double MINIMUM_COST = PropertyIndexLookup.COST_OVERHEAD;
+ static final double MINIMUM_COST = 2.05;
private final NodeState root;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java?rev=1707553&r1=1707552&r2=1707553&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java Thu Oct 8 14:43:58 2015
@@ -939,12 +939,15 @@ public class QueryImpl implements Query
// Sort the indexes according to their minimum cost to be able to skip the remaining indexes if the cost of the
// current index is below the minimum cost of the next index.
- final List<? extends QueryIndex> queryIndexes = MINIMAL_COST_ORDERING
+ List<? extends QueryIndex> queryIndexes = MINIMAL_COST_ORDERING
.sortedCopy(indexProvider.getQueryIndexes(rootState));
-
for (int i = 0; i < queryIndexes.size(); i++) {
- final QueryIndex index = queryIndexes.get(i);
- final QueryIndex nextIndex = (i < queryIndexes.size()) ? queryIndexes.get(i) : null;
+ QueryIndex index = queryIndexes.get(i);
+ double minCost = index.getMinimumCost();
+ if (minCost > bestCost) {
+ // Stop looking if the minimum cost is higher than the current best cost
+ break;
+ }
double cost;
String indexName = index.getIndexName();
@@ -1015,10 +1018,6 @@ public class QueryImpl implements Query
bestIndex = index;
bestPlan = indexPlan;
}
- // Stop looking for a better index if the current best cost is lower than the next minimum cost
- if (nextIndex != null && bestCost <= nextIndex.getMinimumCost()) {
- break;
- }
}
if (traversalEnabled) {