Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Forcing xpath query timeouts

Avatar

Level 4

I have a client that is on AEM 6.2 and I am being asked to set timeouts on xpath searches. Looking at the documents for javax.jcr.query.QueryManager, I don't see any way to do this.

Is there a way to watch a query's execution time and kill the thread after X number of seconds?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Unfortunately that's not possible with the current implementation. But you can set limits how many nodes should be iterated at max.

Jörg

View solution in original post

5 Replies

Avatar

Correct answer by
Employee Advisor

Unfortunately that's not possible with the current implementation. But you can set limits how many nodes should be iterated at max.

Jörg

Avatar

Level 4

That is what I was afraid of. The client has a lot of sites and authors are dumping large numbers of assets, many could be duplicates so the search in the sidekick for assets takes a very long time to return results. Limit would help where assets are found, but not in the case where it takes a long time to complete. That is the biggest problem is limiting queries that take very long to complete. The user might leave the page but the queries run on, consuming CPU cycles that are no longer needed.

Avatar

Community Advisor

Just a thought.

We can try doing multiple searches with limited nodes (1 call for each site) and append results. In this way, we can avoid additional calls if user leaves the page.

Avatar

Level 3

Alternatively you can create oak indexes to optimise your query.

Avatar

Employee Advisor

I guess the only chance to mitigate that is not to kill long-running query but to avoid long-running queries at all. Of course with all combinations used you can create arbitrarily complex queries which take a long time to complete. But I am not really aware of immediate issues where the sidekick is unusable due to slow queries. If that's the case I would contact Adobe support.

Do you have any query which is created by sidekick and which is slow or which is traversing the tree instead of using an index?

Jörg