EPiServer Find vs IContentRepository.GetDescendents()

Vote:
 

Hi,

Using EPiServer CMS 11
Using EPiServer Find 13

I've a requirement to get all decendent pages in couple of places in a site I'm working on, we may also want to narrow the results to a particular type of page.

Is using EPiServer Find a good alternative to GetDescendants? Part of me thinks querying the database by hand may be the fastest option, though that is not as easy to maintain as just using the EPiServer CMS API, but I see other blog posts mentioning that EPiFind may be the best option? This seams dubious to me as EPiFind would require an http call etc etc, while the API should just be able to query the sql server db and get results out real quick, unless EPiFind has some clever caching going on? What is the accepted wisdom on this one?

The use case is we wish to list all blog/news/events/etc pages, and editors add to the list by adding child pages under the parent.

#197450
Edited, Oct 03, 2018 10:29
Vote:
 

IContentRepository.GetDescendents, in most of the cases, a bad choice for performance. Find is simply superior to that, it has better API and is much, much faster.

#197451
Oct 03, 2018 10:36
Vote:
 

Retrieving data from Episerver database is a very expensive operation, especially in Azure.

You could install a profiler like Prefix (https://stackify.com/prefix/) to see what's going on under the hood, and how many requests are sent to a database on page load for non-cached listing pages.

Episerver Find can improve performance, but you should use projections (https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Projections/). Standard .GetContentResult() method retrieves only content IDs from Elasticsearch (search index) while the actual data is fetched from the databases, which might be as slow as IContentLoader.GetDescendents().

When it comes to caching, you could also take a look at ContentOutputCache (https://world.episerver.com/documentation/class-library/?documentId=cms/7/14a5c664-1e28-e329-2d1d-9d862485c529) and object caching using ISynchronizedObjectInstanceCache (https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Caching/Object-caching/)

#197461
Edited, Oct 03, 2018 12:22
Vote:
 

A word of caution regarding Stackify https://vimvq1987.com/a-curious-case-of-memory-dump-diagnostic-how-stackify-can-cause-troubles-to-your-site/, especially if you are using Application Insights.

Regardless of what method you are using, I completely agree with Dejan - this sounds like a heavy task - and you should cache the result for later uses. 

#197462
Oct 03, 2018 12:30
Vote:
 

Adding that you should add some container or sub listing pages (somehing like a year-month structrure or similiar) below the blog/news/events so that the editors don't put hundreds of pages as direct children.

Find is superior especially when the amount of decendents grow. I would say anything over perhaps just 50 items works a lot faster in Find when you need to sort by some data and get the .Top(x). Sorting and returned items might be not 100% correct at all times if indexing has a queue but I've never heard of this being an actual problem somewhere.

If you put paging in place (bad UX to show huge lists anyway) I wouldn't worry at all about GetContentResult() since the actual db call would be GetContents(pagesize ID array) and by using that you are sure that the actual data shown is correct and that you get the live published version.

#197551
Oct 06, 2018 8:26
Vote:
 

One thing to remember here though is that even that Find usually is faster it is an external call and there is a lot more that can go wrong with it, like http-traffic, Amazon or Azure beeing down, Find beeing down, someone has deleted the index, something has gone wrong when indexing so there is not all content there, you have excluded to much so you will not find what you need, the index has been full so no new item are being indexed and so on and so on.

Find is great for search and for listning pages but I would never use it for system critical tasks (I have accually removed it in a couple of places since it was so unstable with server going down a lot).

So use Find, but use it smart!

#197561
Oct 07, 2018 21:05
Vote:
 

It sounds like you making a case for both techiniques? 

#197569
Oct 08, 2018 10:57
Vote:
 

It's more Henrik making a case for both techniques in some type of fallback pattern when Find service has issues.

When you reach a certain level of items it's really hard to accomplish though since Find is really good with searching/listing from big pools of items but the local internal APIs are not.

GetContentResult() is a method you use on your Find query. It works using a remote Find HTTP call (or not if results are in the cache already) that will return an array of content IDs for the skip/take and sorting you specified. Then it uses a "local" Epi API call to populate the ContentData for each ID. I tried to clarify that the listing might not be "live" but each ContentData in it will be (on its own).

#197571
Edited, Oct 08, 2018 12:38
Vote:
 

ah, my apologies missed that slight detail that makes all the difference.

#197584
Oct 08, 2018 17:14
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.