Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to ensure my Umbraco site is using the most efficient way to get back large sets of data as the site grows. From reading the Common Pitfalls documentation, querying via XPath seems the way to go.
I understand how to get back all documents based on a property or alias. However, I cannot seem to find a way to get back documents based on a path using ContentAtXPath method.
Umbraco.ContentAtXPath("//* [@isDoc]/descendant::/Blog [@isDoc]")
I am trying to run that within a SurfaceController.
I've seen other posts where quite nice querying was carried out in older versions of Umbraco including sorting etc.
I'd appreciate if someone could point me in the right direction.
It's all change in Umbraco V8!!
In V7 and previous versions the published cache of content was stored as an XML file in memory, and consequently XPATH was generally always the quickest fastest way to retrieve things...
... But in V8 the published cache is stored using a new NuCache mechanism which is not in XML format, (XPATH has been retained, for some of the concepts in Umbraco like 'setting the start node in a multinode tree picker' - but it is no longer suggested to use XPATH for querying on your site implementation - you can - but it's no longer the 'quickest' method.
The common pitfalls documentation hasn't been updated for V8!
Paul Seal and Tim Payne gave a talk at Umbraco Spark - earlier this year regarding their investigations into peformance and querying in V8 and their slides are available here;
The slides have some useful examples, and show the timings of accessing content in different ways between V7 and V8.. showing of the places where certain strategies are faster than others.
Thanks for the additional info and I have just gone through Paul and Tim's slides.
Just to be sure I am understanding correctly, LINQ operations seem to be quicker in all the performance tests. So if I had 5000 pages and needed to do the following query:
IEnumerable<IPublishedContent> umbracoPages = startPage
.Where(p => !p.Value<bool>("navigationHide"))
.OrderBy(p => p.SortOrder);
That wouldn't considered bad practice as I am getting backing all the types of "blogpost", just getting back 5 items and then ordering?
Yes, I think that is the conclusion they came to.
You can always measure how long a piece of code takes to execute on your site, using the MiniProfiler: and wrapping the lines of code in an IProfiler 'step'
But although it goes against all the ingrained Umbraco knowledge of previous versions, Linq with NuCache is the suggested approach.
If you are filtering by 'text' eg Where(f=>f.Value
... it depends on the context, but if you use the Miniprofiler you can be sure in your context what the expense of a particular query is.
This is just a thought, and don't know if it will work, but if you put the take / skip before the .DescendantsOfType("blogpost") does it still loop through all the nodes?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted