@akshaybhujbale
You definitely need to optimize your query.
Make sure you query in the deepest possible level in the hierarchy.Get rid of p.limit=-1. You are trying to get pages in a single hit.
Unless you are already not optimizing query based on paths, it was bound to fail, as the repository ...