jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1404899 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/index/old/ query/ spi/query/
Date Fri, 02 Nov 2012 09:08:59 GMT
Author: thomasm
Date: Fri Nov  2 09:08:59 2012
New Revision: 1404899

URL: http://svn.apache.org/viewvc?rev=1404899&view=rev
Log:
OAK-404 Log (slow) queries (log all queries and query plans with log level 'debug')

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixIndex.java?rev=1404899&r1=1404898&r2=1404899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixIndex.java
Fri Nov  2 09:08:59 2012
@@ -132,5 +132,10 @@ public class PrefixIndex implements PInd
     public boolean isUnique() {
         return tree.isUnique();
     }
+    
+    @Override
+    public String toString() {
+        return getIndexNodeName();
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java?rev=1404899&r1=1404898&r2=1404899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java
Fri Nov  2 09:08:59 2012
@@ -112,5 +112,10 @@ public class PropertyContentIndex implem
             return false;
         }
     }
+    
+    @Override
+    public String toString() {
+        return index.toString();
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndex.java?rev=1404899&r1=1404898&r2=1404899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndex.java
Fri Nov  2 09:08:59 2012
@@ -136,5 +136,10 @@ public class PropertyIndex implements PI
     public boolean isUnique() {
         return tree.isUnique();
     }
+    
+    @Override
+    public String toString() {
+        return getIndexNodeName();
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java?rev=1404899&r1=1404898&r2=1404899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
Fri Nov  2 09:08:59 2012
@@ -53,6 +53,8 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Represents a parsed query. Lifecycle: use the constructor to create a new
@@ -72,6 +74,8 @@ public class Query {
      */
     public static final String JCR_SCORE = "jcr:score";
 
+    private static final Logger LOG = LoggerFactory.getLogger(QueryEngineImpl.class);
+
     final SourceImpl source;
     final ConstraintImpl constraint;
     final HashMap<String, PropertyValue> bindVariableMap = new HashMap<String, PropertyValue>();
@@ -308,6 +312,9 @@ public class Query {
                     null);
             it = Arrays.asList(r).iterator();
         } else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("plan: " + source.getPlan(root));
+            }
             if (orderings == null) {
                 // can apply limit and offset directly
                 it = new RowIterator(root, limit, offset);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java?rev=1404899&r1=1404898&r2=1404899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
Fri Nov  2 09:08:59 2012
@@ -30,6 +30,8 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The query engine implementation.
@@ -41,6 +43,8 @@ public class QueryEngineImpl {
     static final String XPATH = "xpath";
     static final String JQOM = "JCR-JQOM";
 
+    private static final Logger LOG = LoggerFactory.getLogger(QueryEngineImpl.class);
+
     private final NodeState root;
     private final QueryIndexProvider indexProvider;
 
@@ -68,6 +72,9 @@ public class QueryEngineImpl {
 
     private Query parseQuery(String statement, String language) throws ParseException {
         Query q;
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(language + ": " + statement);
+        }
         if (SQL2.equals(language) || JQOM.equals(language)) {
             SQL2Parser parser = new SQL2Parser();
             q = parser.parse(statement);
@@ -79,6 +86,9 @@ public class QueryEngineImpl {
             XPathToSQL2Converter converter = new XPathToSQL2Converter();
             String sql2 = converter.convert(statement);
             SQL2Parser parser = new SQL2Parser();
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("XPath > SQL2: " + sql2);
+            }
             try {
                 q = parser.parse(sql2);
             } catch (ParseException e) {
@@ -114,12 +124,18 @@ public class QueryEngineImpl {
         double bestCost = Double.MAX_VALUE;
         for (QueryIndex index : getIndexes()) {
             double cost = index.getCost(filter, root);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("cost for " + index + " is " + cost);
+            }            
             if (cost < bestCost) {
                 bestCost = cost;
                 best = index;
             }
         }
         if (best == null) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("no indexes found - using TraversingIndex; indexProvider: " + indexProvider);
+            }
             best = new TraversingIndex();
         }
         return best;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java?rev=1404899&r1=1404898&r2=1404899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java
Fri Nov  2 09:08:59 2012
@@ -69,5 +69,10 @@ public class CompositeQueryIndexProvider
         }
         return indexes;
     }
+    
+    @Override
+    public String toString() {
+        return getClass().getName() + ": " + providers.toString();
+    }
 
 }



Mime
View raw message