The Problem
Every Adobe Experience Manager developer eventually encounters an exception indicating that the node reading limit has been exceeded:
1
2
3
4
5
java.lang.UnsupportedOperationException: The query read or traversed more than 100000 nodes.
To avoid affecting other tasks, processing was stopped.
at org.apache.jackrabbit.oak.query.FilterIterators.checkReadLimit(FilterIterators.java:70)
at org.apache.jackrabbit.oak.plugins.index.Cursors.checkReadLimit(Cursors.java:67)
at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$LucenePathCursor$1.next(LucenePropertyIndex.java:1730)
This error occurs when a JCR-SQL2 or XPath query reads or traverses more than 100,000 nodes without finding an applicable index. Oak aborts the query to prevent it from degrading system performance.
Root Causes
- Missing index: No Oak index covers the properties used in the query WHERE clause.
- Missing path restriction: The query lacks
ISDESCENDANTNODEorISCHILDNODE, causing a full repository scan. - Leading wildcards: Using
LIKE '%term%'forces a traversal since standard property indexes cannot satisfy leading wildcard patterns. - Inefficient node types: Querying
nt:unstructuredorsling:OrderedFolderwhen a more specific type would suffice.
Solutions
Production Fixes
-
Define an Oak index for the properties used in your query. Create a property index for equality lookups or a Lucene index for full-text search.
-
Add a path restriction to every query using
ISDESCENDANTNODEorISCHILDNODE. This limits the search scope and helps the query engine select the correct index. -
Update existing indexes to cover additional properties if your query has evolved.
-
Use efficient node types: prefer
oak:Unstructuredovernt:unstructuredandsling:Folderoversling:OrderedFolderwhen ordering is not required. -
Consider architectural changes: if queries consistently hit the limit, the repository structure may need reorganization.
Development Workaround
During development only, you can temporarily increase the read limits:
- Navigate to QueryEngineSettings in the JMX console:
1
http://localhost:4502/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3Dsettings%2Ctype%3DQueryEngineSettings
- Increase the
LimitReadsandLimitInMemoryparameters.
Warning: This is a development-only workaround. Never deploy increased limits to production, as it masks underlying performance problems and can cause system instability.
Further Reading
For a comprehensive guide to JCR-SQL2 query syntax, indexing strategies, and debugging techniques, see the JCR-SQL2 Query with Examples post.