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 to...@apache.org on 2018/10/10 09:34:48 UTC
svn commit: r1843416 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
Author: tommaso
Date: Wed Oct 10 09:34:48 2018
New Revision: 1843416
URL: http://svn.apache.org/viewvc?rev=1843416&view=rev
Log:
OAK-7795 - Log a debug message when two or more indices have same or very close cost amounts
Modified:
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/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=1843416&r1=1843415&r2=1843416&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 Wed Oct 10 09:34:48 2018
@@ -974,6 +974,10 @@ public class QueryImpl implements Query
double bestCost = Double.POSITIVE_INFINITY;
IndexPlan bestPlan = null;
+ // track similar costs
+ QueryIndex almostBestIndex = null;
+ double almostBestCost = Double.POSITIVE_INFINITY;
+
// 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.
List<? extends QueryIndex> queryIndexes = MINIMAL_COST_ORDERING
@@ -1042,12 +1046,25 @@ public class QueryImpl implements Query
if (cost < 0) {
LOG.error("cost below 0 for " + indexName + " is " + cost);
}
+
if (cost < bestCost) {
+ almostBestCost = bestCost;
+ almostBestIndex = bestIndex;
+
bestCost = cost;
bestIndex = index;
bestPlan = indexPlan;
+ } else if (cost - bestCost <= 0.1) {
+ almostBestCost = cost;
+ almostBestIndex = index;
}
}
+
+ if (LOG.isDebugEnabled() && Math.abs(bestCost - almostBestCost) <= 0.1) {
+ LOG.debug("selected index {} and {} have similar costs {} and {} for query {} - check query explanation / index definitions",
+ bestIndex, almostBestIndex, bestCost, almostBestCost, filter.toString());
+ }
+
potentiallySlowTraversalQuery = bestIndex == null;
if (traversalEnabled) {
TraversingIndex traversal = new TraversingIndex();