The last foreach takes about 3 seconds! The first one 1 second. How is this posible? For the second foreach there are around 5000 nodes but only a view will be displayed in the menu.
Are your "Region" doctypes direct children of your node with Id 1195. If so you can probably speed up things by using Children instead of descendants. Descendants will get all underlying nodes no matter the level. And then will perform the filtering.
You can probably cache this macro for a long time, so you only have this performance hit on the first time it's rendered.
The Children of the second level (the second foreach) contains 5000 nodes, using this:
doc.Children.Where("NodeTypeAlias == \"Regio\"")
Takes around 7 seconds.
I am using Cache, but still Umbraco gets very very slow when using a lot of nodes. If a visitor has to wait 10 seconds for a (uncached) page to load it's just slow.
We are currently using Umbraco v6.2.4. As i did some reading i noticed the Razor Macro's are still there for legacy. I switched the script to a partial view macro:
Slow content loading with IPublishedContent
Hello :)
I Have the following code:
@using umbraco; @using umbraco.MacroEngines; @using Umbraco.Web; @using Umbraco.Core; @inherits umbraco.MacroEngines.DynamicNodeContext @{
}
The last foreach takes about 3 seconds! The first one 1 second. How is this posible? For the second foreach there are around 5000 nodes but only a view will be displayed in the menu.
Does anyone has some tips?
Trace:
umbracoMacro Loading Macro Script Context (file: Navigatie) 1,661313 1,607701 umbracoMacro Loading Macro Script Context (file: Navigatie) 1,661422 0,000108 umbracoMacro Done Loading Macro Script Context (file: Navigatie) 1,661463 0,000041 umbracoMacro Boxing Macro Script MacroContext (file: Navigatie) 1,661495 0,000032 umbracoMacro Done Boxing Macro Script MacroContext (file: Navigatie) 1,661524 0,000029 umbracoMacro Loading Macro Script Model (file: Navigatie) 1,661551 0,000027 umbracoMacro Done Loading Macro Script Model (file: Navigatie) 1,661619 0,000068 umbracoMacro Done Loading Macro Script Context (file: Navigatie) 1,661647 0,000028 umbracoMacro Executing Macro Script (file: Navigatie) 1,661676 0,000029 Start navigatie 1,663897 0,002220 Umbracohelper opgehaald 1,663956 0,000059 content opgehaald 1,664852 0,000897 Hoogste foreach 1,664906 0,000053 Sub foreach 1,689987 0,025082 Sub foreach klaar 5,501504 3,811516 Hoogste foreach klaar 5,501659 0,000155 umbracoMacro Done Executing Macro Script (file: Navigatie) 5,501726 0,000067 End: Executing MacroEngineScript: Navigatie.cshtml 5,501888 0,000161 End: Render Macro: Navigatie, type: Script, cache: 0) 5,501957 0,000069
Are your "Region" doctypes direct children of your node with Id 1195. If so you can probably speed up things by using Children instead of descendants. Descendants will get all underlying nodes no matter the level. And then will perform the filtering.
You can probably cache this macro for a long time, so you only have this performance hit on the first time it's rendered.
Dave
The Children of the second level (the second foreach) contains 5000 nodes, using this:
doc.Children.Where("NodeTypeAlias == \"Regio\"")
Takes around 7 seconds.
I am using Cache, but still Umbraco gets very very slow when using a lot of nodes. If a visitor has to wait 10 seconds for a (uncached) page to load it's just slow.
5000 nodes is a lot of children for one node. This is also not workable from a editors point of view.
Maybe you can structure them in folders.
Can you try this :
doc.Children.Where(x => x.DocumentTypeAlias == "Regio")
This is strongly type, while the code you have uses dynamic. Using dynamics can be a performance hit when used in where clauses.
Dave
Yhe, we are working on a solution for that.
The solution you provide takes 3,250178 seconds. With caching it isn't even thinking about it anymore.
Some more optimizations are necessary. But it's a step in the right direction.
Thanks for you support!
Can I ask what version of Umbraco you are using ? I see you are still using the old razor engine.
Since Umbraco v4.10 you can use partial view macro's : https://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/
Dave
We are currently using Umbraco v6.2.4. As i did some reading i noticed the Razor Macro's are still there for legacy. I switched the script to a partial view macro:
Do you have any more suggestions? :)
Hello,
You could try to cach the entire page with Donut Caching. I'm also using it in the Hybrid Framework. There are 2 versions.
Hybrid Framework Umbraco 6.
Hybrid Framework Umbraco 7.
For Umbraco 6 I explain in this video how to use it: https://www.youtube.com/watch?v=rubA5k5cnxE.
These topics might also help:
https://our.umbraco.org/projects/developer-tools/hybrid-framework/hybrid-framework/48007-Donut-caching-Profiles
https://our.umbraco.org/projects/developer-tools/hybrid-framework/hybrid-framework/45020-Implementing-Donut-Caching-and-MVC-part-in-existing-solution
Jeroen
is working on a reply...