Performance | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

When you need to find that on a single page, use the iterator approach; the static overhead of queries is typically higher than the cost of iterating.

4 replies

gkalyan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 25, 2024

@keerthi0555 

It depends on couple of things: How complex is the query and how many nodes you are planning to traverse.

For a small number of nodes, iterating through JCR nodes using a node iterator is often more efficient.
For larger node sets or when dealing with more complex queries, it's generally better to set up Oak indexes and use QueryBuilder.
 
This best practices guides on queries and indexing might help, try checking this out 
 
VeenaVikraman
Community Advisor
Community Advisor
June 25, 2024

@keerthi0555 Node iteration is always faster and performance efficient that Query Builder. If you know the exact path to iterate and get the values , I would say use Node Iteration.  

 

Please find a more detailed explanation from @joerghoh https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/child-node-iterating/m-p/305931/highlight/true#M28258 

Anudeep_Garnepudi
Community Advisor
Community Advisor
June 26, 2024

@keerthi0555 

If you want to iterate through all the resources then go with iterator.

If you want a specific resource(s) with specific property then search using query builder.

Depends on your use case. 

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
June 30, 2024

When you need to find that on a single page, use the iterator approach; the static overhead of queries is typically higher than the cost of iterating.