Query Builder and Oak Indexing
Understand how Query Builder, JCR SQL2, and Oak indexes work together to keep AEM queries safe in production.
Last reviewed: June 2026
🔍 What Is It?
AEM teams use:
- →Query Builder for predicate-based repository searches
- →JCR SQL2 for more explicit query logic
- →Oak indexes to make those queries performant
Query syntax is the easy part. Index support, path scoping, ordering, and result limits are the real production concerns.
🎯 Why Do We Need It?
Search and listing features are everywhere in AEM:
- →article pages list related content
- →DAM views filter assets by metadata
- →components fetch authored content by tag or model
- →support tools inspect content state
Without disciplined query design, small features create large repository load.
🏗️ What Happens in Real Projects?
A team may build a "Latest News" component using Query Builder, but if the predicate is unbounded or unsupported by indexes, Publish latency rises under load. A safer implementation aligns predicates, path restrictions, sort fields, and result limits with a tested Oak index.
⚙️ How It Works
Healthy query flow:
- Start with a precise business need
- Restrict path, type, and fields
- Choose Query Builder or JCR SQL2 based on clarity
- Validate the explain plan
- Add or adjust Oak indexes when needed
- Set limits and fallbacks so a slow query cannot fan out across the repository
💻 Example
Safe query checklist — A practical pattern for repository-backed listing components.
🤔 Common Confusions
❓ Is Query Builder always better than SQL2 because it is more "AEM native"?
No. Query Builder is convenient, but SQL2 can be clearer for some use cases. The decisive factor is correctness, readability, and index support.
❓ If the query works locally, is it production-safe?
Not necessarily. Small datasets can hide traversal and sort problems that appear only under real content volume.
🚨 Common Production Issues
A component works in lower environments but times out in production after content volume crosses an index threshold.
An authoring console becomes slow because DAM metadata filters were added without index review.
Teams blame Dispatcher or CDN for latency that actually begins in Oak query cost.
✅ Best Practices
Review query plans with realistic content volume.
Prefer narrow repository scopes and explicit limits.
Treat index changes as platform changes with validation, not as casual fixes.
🏛️ Architect's Note
Query governance should be part of AEM platform standards. A site can survive one inefficient component, but repeated "small" query shortcuts across brands and regions become an expensive operational habit.
💬 Frequently Asked Questions
🎯 Key Takeaways
🔗 Related Topics
🎯 Practice this topic in interviews
↗ Where this topic fits
AEM Technology Guide
Return to the AEM learning hub.
AEM Developer Career Path
This AEM developer career path explains how to become an AEM developer through JCR, Sling, HTL, client libraries, Dispatcher, Cloud Service delivery, project depth, and interview-ready enterprise implementation skills.
Drupal Developer Career Path
A practical route through Drupal content modeling, site building, theming, modules, configuration management, APIs, performance, deployment discipline, and interview preparation.
Sources
Sources / References
Use these AEM references to verify the concept in official docs and continue into the most relevant SplashRide pages.
Official documentation
Related SplashRide pages
SplashRide AEM learning path
Browse the full AEM topic collection and learning order on SplashRide.
AEM Interview Prep
Practice AEM interview questions and scenario-based answers.
AEM Developer Career Path
This AEM developer career path explains how to become an AEM developer through JCR, Sling, HTL, client libraries, Dispatcher, Cloud Service delivery, project depth, and interview-ready enterprise implementation skills.
Drupal Developer Career Path
A practical route through Drupal content modeling, site building, theming, modules, configuration management, APIs, performance, deployment discipline, and interview preparation.
JCR (Java Content Repository)
Learn what the JCR is, how AEM uses it to store everything, and why understanding it is fundamental to AEM development.
Oak Repository Basics
Learn how Apache Jackrabbit Oak underpins AEM storage, indexing, queries, and operational trade-offs.