Most efficient way to get content by DocumentType / ContentType in V8
Hi!
I know that in Umbraco 7 when the XML-cache was still around the most efficient way to fetch all content nodes by its document type would be something like:
var blogPosts = Umbraco.TypedContentAtXPath("//BlogPost");
But in V8, with NuCache storing the object instances I guessing that a XPath-query would force all nodes to have to "convert" in to XML to perform a query like this? It feels like this could be a performance nightmare?
Also this would perform some nested loop to query lots and lots of objects:
var blogPosts = StartModel.Descendants<BlogPost>()
What I can think of right now would be to use Examine to get all the nodes and then load them from the content cache, but maybe there is a better way?
Anyone who knows what would be the most efficient way to query/load all nodes based on Document Type?
Thanks @Harikrishna, I know that this is an option but also might not be the best option since it will loop over all content in the entire site. In V7 this was quite slow. I guess this would work but I was looking for a solution similar to the one I posted but for V8.
Until then I ended up using Examine to search for all the content and fetch the ones I need from the Content Cache.
Most efficient way to get content by DocumentType / ContentType in V8
Hi!
I know that in Umbraco 7 when the XML-cache was still around the most efficient way to fetch all content nodes by its document type would be something like:
But in V8, with NuCache storing the object instances I guessing that a XPath-query would force all nodes to have to "convert" in to XML to perform a query like this? It feels like this could be a performance nightmare?
Also this would perform some nested loop to query lots and lots of objects:
What I can think of right now would be to use Examine to get all the nodes and then load them from the content cache, but maybe there is a better way?
Anyone who knows what would be the most efficient way to query/load all nodes based on Document Type?
// m
Did you ever find an answer for this?
Seems very relevant even today. Hopefully this post will bring the subject back to life?
J
Hi,
Xpath is really only in v8 for use with the Multi node tree picker.
If I remember correctly:
Linq is faster with a smaller amount of content vs Examine (depending on how its used)
Paul Seal and Tim Payne did a talk on this at Umbraco Spark eariler this year the test repo is here -
https://github.com/prjseal/TestingUmbracoPerformance
(you will need to run it to see the results)
I know offroadcode have seen different results in some cases.
Matt
EDIT - Slides are on https://umbracospark.com/
Hi Markus, I think this will help you.
Does Model.Root have Ancestors?
Do you mean DescendantsOrSelf?
Hi!
Thanks @Harikrishna, I know that this is an option but also might not be the best option since it will loop over all content in the entire site. In V7 this was quite slow. I guess this would work but I was looking for a solution similar to the one I posted but for V8.
Until then I ended up using Examine to search for all the content and fetch the ones I need from the Content Cache.
// m
is working on a reply...