Querying content

Hi

I have news articles section as follows News/Year/Month/newsArticle, about 10,000 approx news articles.

i make use of var newsArticle = Model.Decendants<IPublishedContent>().where(x => x.IsVisable() && x.IsDocumentType(“news“)).OrderByDececnding(x => x.CreateDate);

When loading page, it takes about 5 minutes to load initially, after that its loads as expected without delay.

My query is what is happening on initial load ?

Is the query hitting the database on initial load or memory cache?

How best to improve initial load ?

Dibs

Over querying is happening way to ofter. We’ve had the same issue recently:
”Give me all content nodes of type x where the value of property y = value1 and property z = value2”.

The ‘Descendants’ will already get all descendants and THEN you filter on it multiple times. First of, instead of Descendants, you can use DescendantsOfType, that will already eliminate some of the issues.

But really, if you are making complex queries, I’d always use the external index. I went from a query could take up to 5 seconds, to a query that took around 100ms.

This happens because the cache since v15 has been lazyloaded. By default it finds the first 100 nodes and puts those into the cache, everything else is not cached until its accessed.

So when you query your archive of 10.000 articles it has to pull them out of the database and into the cache on the first visit.

As @Luuk suggests. with that number of articles, you probably should look into using Examine to query them, when you have that many.

But for now, to replicate performance from before the lazy loaded cache, you can make Umbraco put them all into cache on startup, by tweaking some configuration.

Thanks guys

I made use of

“Umbraco”: {
“CMS”: {
“Cache”: {
“ContentTypeKeys”: [“e811405e-0190-4d3e-8387-7558521eec81”, “419e89fb-8cff-4549-a074-9f8a30687828”, “e0d71146-8205-4cf4-8236-f982b392259f”],
}
}
}

for testing and improved greatly.

I may well go down the route of making use of Examine, as suggested.

Should i do it anyway, as more content will eventually lead to more memory required for cache and performance issues. Or would i get the same issues with more content for Examine when creating/updating indexes ?

Dibs

Instead of “guys”, may we suggest, for example: “folks", “Umbracians”, “all”, or “everyone”? We use gender inclusive language in this forum :grinning_face: (read more)