Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jin 2 posts 71 karma points
    Feb 21, 2017 @ 18:21
    Jin
    0

    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.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 21, 2017 @ 19:37
    Dirk De Grave
    1

    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

  • Jin 2 posts 71 karma points
    Feb 21, 2017 @ 21:24
    Jin
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft