Skip to main content
Level 2
Oct 16, 2015 2:29 AM UTC
Solved

Query getNodes() Extremely Slow

I am building a query using QueryBuilder and the query returns 32k results.  I am using the following to create an Iterator so that I can index over each result.  

 

Iterator<Node> itr =  query.getResult().getNodes();

 

This line however takes a really long time and is slowing my page down drastically.  How can I speed this up?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Adobe Employee
Oct 16, 2015 2:29 AM UTC

In Jackrabbit and Oak the complete execution time of a query always consists of the exucution of the query itself and the retrieval of the results. This is because it's quite common that you're query returns lot of results, but you never retrieve them all, so it is split. And 32k results is quite a number.

I am not in the details, but for me it looks like that this command (especially the query.getResult() part) takes that long because it fetches a good number of results from the repository. And this means not only only loading nodes, but there are also a lot of other acitivites (e.g. validating ACLs, so you only the pages you have at least read access to, etc.).

kind regards,
Jörg

9 replies

Peter_Puzanovs
Community Advisor
Community Advisor
Oct 16, 2015 2:29 AM UTC

QueryBuilder is great fun to use and improve :)

Does your query contains search for custom fields you have created ?

When you go inside the /system/console/jmx/com.adobe.granite%3Atype%3DQueryStat do you see your query there ?

 

Thanks,

Peter

Translate
joerghoh
Adobe Employee
Adobe Employee
Oct 16, 2015 2:29 AM UTC

When you use "order by", the complete result set must be loaded from the repo in order to get sorted properly. Try to avoid ordering if you don't need it, it can speed up the performance significantly.

kind regards,
Jörg

Translate
Adobe Employee
Oct 16, 2015 2:29 AM UTC

Can you share the query with us?

Translate
Level 2
Oct 16, 2015 2:29 AM UTC

Jörg Hoh wrote...

In Jackrabbit and Oak the complete execution time of a query always consists of the exucution of the query itself and the retrieval of the results. This is because it's quite common that you're query returns lot of results, but you never retrieve them all, so it is split. And 32k results is quite a number.

I am not in the details, but for me it looks like that this command (especially the query.getResult() part) takes that long because it fetches a good number of results from the repository. And this means not only only loading nodes, but there are also a lot of other acitivites (e.g. validating ACLs, so you only the pages you have at least read access to, etc.).

kind regards,
Jörg

 

Then this means there is nothing I can do to increase the speed of this function?

Translate
Level 2
Oct 16, 2015 2:29 AM UTC

Pacoolsky wrote...

what is the exact query ? does it contain order by clause ?

 

Yes, it does Order By

Translate
Level 2
Oct 16, 2015 2:29 AM UTC

So, there is really no way to speed this process up?

Translate
joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
Oct 16, 2015 2:29 AM UTC

In Jackrabbit and Oak the complete execution time of a query always consists of the exucution of the query itself and the retrieval of the results. This is because it's quite common that you're query returns lot of results, but you never retrieve them all, so it is split. And 32k results is quite a number.

I am not in the details, but for me it looks like that this command (especially the query.getResult() part) takes that long because it fetches a good number of results from the repository. And this means not only only loading nodes, but there are also a lot of other acitivites (e.g. validating ACLs, so you only the pages you have at least read access to, etc.).

kind regards,
Jörg

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Oct 16, 2015 2:29 AM UTC

Do you see any warnings in the log-file? (error.log)

Translate
Pacoolsky
Level 2
Oct 16, 2015 2:29 AM UTC

what is the exact query ? does it contain order by clause ?

Translate