What is the most performant way to get all the con...
# help-with-umbraco
m
The GetContentByType method seems to walk down the entire tree which doesn't sound really performant on large trees. Should we get it from Examine or query the database to get the ID's and then use GetContentById for each one? Or am I stressing about nothing and isn't it a problem if we walk down the entire tree? https://cdn.discordapp.com/attachments/1184477141291774064/1184479616111480832/image.png?ex=658c1f9b&is=6579aa9b&hm=075eecec104e8aa969ab67d933e9152405ded94c521c540b92828644b85d2991&
The GetContentByType is implemented in this way (also check the comment)
j
This really depends on the nature of the tree itself. The cache is in memory, so it's not going to be slow to search through. If you can narrow the query down i.e. get content by type, that are children/descendants of a specific node, then you may be able to speed that up - IME this is usually more than fast enough as it's unusual to need to look for random doctypes that could be anywhere in the tree. If your tree is huge, and you need to search all of it, then making a db/examine call first might be faster but the only way to know is to test it against your actual content.
I'd recommend going for examine over a DB call to avoid the IO.
2 Views