Hi, I am trying to query all sub nodes with a special type from a node.
Currently I have it like this inside the template:
var collectionNode = CurrentPage.Descendants("items").Where("Visible").OrderBy("date desc");
The problem is that it takes 45 seconds for it to load. There's ~1000+ sub nodes for it to loop into and get it back in the collection.
Is there a better way to do it? Or am I doing it wrong?
Thanks.
Short answer: don't use Descendants() on a large node base, it's going to hurt (as you already found out). Better go with old school XPath querying or use Examine for more complex selecting/sorting
Unfortunately I have to get the content from the nodes and fetch it onto a table. The article clearly stated the issue, but the suggestion doesn't seen to fit my problem. I guess I will have to do a pagination on only obtaining x amounts of sub nodes contents and not all of it at once.
Will also try XPath or Examine and see how it goes.
Faster way to query large amount of nodes?
Hi, I am trying to query all sub nodes with a special type from a node. Currently I have it like this inside the template:
var collectionNode = CurrentPage.Descendants("items").Where("Visible").OrderBy("date desc");
The problem is that it takes 45 seconds for it to load. There's ~1000+ sub nodes for it to loop into and get it back in the collection. Is there a better way to do it? Or am I doing it wrong? Thanks.
Hi Jin,
Short answer: don't use Descendants() on a large node base, it's going to hurt (as you already found out). Better go with old school XPath querying or use Examine for more complex selecting/sorting
See https://our.umbraco.org/documentation/Reference/Common-Pitfalls/ why it's not a good idea to use Descendants() and a couple of suggestions on how to improve (more near the bottom)
Hope it helps a bit.
--Dirk
Hi Dirk,
Thanks for the help.
Unfortunately I have to get the content from the nodes and fetch it onto a table. The article clearly stated the issue, but the suggestion doesn't seen to fit my problem. I guess I will have to do a pagination on only obtaining x amounts of sub nodes contents and not all of it at once.
Will also try XPath or Examine and see how it goes.
-Jin
is working on a reply...