QueryResult.getRows() returning very slowly | Community
Skip to main content
October 16, 2015
Solved

QueryResult.getRows() returning very slowly

  • October 16, 2015
  • 2 replies
  • 975 views

I'm doing a very simple query to find tags that match a given search term: 

ex) select * from [cq:Tag] as item where  contains(*,'queryTerm')  and  isdescendantnode(item, '/etc/tags/TagNamespace')

I am not using QueryBuilder. I'm using the JCR Query API directly. The query is executing very quickly never taking more than 44ms. However, when I try to retrieve the results from the query with QueryResult.getRows() or QueryResult.getNodes() my application consistently hangs for anywhere from 10,000 - 20,000 ms. Even more odd, I see these same slow times when there are no query results. 

I'm seeing this on AEM 6.0. 

Any thoughts would be most appreciated. 

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

Hi,

In the jackrabbit implementation a JCR query is split into 2 parts: the execution and then fetching of the results. The result is returned lazy, therefor the decision was made to deliver the first results fast and accept a delay when displaying further results. This is different to common SQL databases, where you get your result set all at once (after a potential slow execution). So to judge the performance of a query, you always have to consider the execution and the time to fetch.

kind regards,
Jörg

2 replies

joerghoh
joerghohAccepted solution
Employee
October 16, 2015

Hi,

In the jackrabbit implementation a JCR query is split into 2 parts: the execution and then fetching of the results. The result is returned lazy, therefor the decision was made to deliver the first results fast and accept a delay when displaying further results. This is different to common SQL databases, where you get your result set all at once (after a potential slow execution). So to judge the performance of a query, you always have to consider the execution and the time to fetch.

kind regards,
Jörg

smacdonald2008
New Participant
October 16, 2015

Generally the JCR API will be faster as its a lower level API.  See this article:

http://www.cqtutorial.com/courses/cq-admin/cq-admin-lessons/cq-performance-tuning/cq-search-performance-tuning