Using QueryDebugger or Page API to loop over pages?
I have come accross this legacy code on a project and I am in the process of refactoring it. I am wondering if I should use the QueryBuilder API to get all pages on which I need to perform an operation, or if I should recursively loop over the Page and its children to perform said operation.
The current implementation recursively loops over a page and its children.
private void method(final Page page, final String data) {
if (pageUtil.pageMatchesCondition(page)) {
final Resource contentResource = page.getContentResource();
if (pagePropertiesService != null) {
pagePropertiesService.updatePageProperties(contentResource, data);
}
}
page.listChildren().forEachRemaining(childPage -> {
method(childPage, data);
});
}
During local development and debugging, it seemed the QueryBuilder API was much faster.
But I read a post from @joerghoh saying that the iterator is usually faster at https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/find-first-level-child-using-query/m-p/188361/highlight/true#M107162. But for my current use case I am not entirely sure what to do best.