Performance | Community
Skip to main content
Keerthi0555
New Participant
June 25, 2024
Solved

Performance

  • June 25, 2024
  • 4 replies
  • 953 views

Hi Aem-community,

Is it better use node iterator or querybuilder to find components on page and get properties of components?

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

joerghoh
joerghohAccepted solution
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.

Anudeep_Garnepudi
New Participant
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. 

VeenaVikraman
New Participant
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 

gkalyan
New Participant
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