One of our sites is experiences performance issues. Using the umbDebugShowTrace I have narrowed it down to a specific XSLT file. Now, I have checked it over, and the only parts that (to me anyway) seem like they could be the cause are the for-each loops we use. I have however, no idea of how to get the data I need with another (more optimized) Xpath expression. If someone could take a look at this that'd be great.
Why do you use 'descendant-or-self' and 'ancestor-or-self'? at one time?
$currentPage/ancestor-or-self::*[@isDoc]/descendant-or-self::*[@isDoc] [umbraco.library:HasAccess(@id,@path) and string(naviHide) != '1' and (self::Nieuws or self::Pagina) and @level > 0]
It's to build up the menu correctly. No matter the current page I am on, I ALWAYS want to start from the top. So, using ancestor-or-self I go to the root, and then grab everything below it.
As I stated, I am pretty sure that is indeed the bottleneck. But I have no idea what would be a more efficient XPATH expression. Maybe I should add my node structure:
Whatever page I am on, I need to build a menu for the corresponding site (Dutch, Flemish or French). The menu items are the categories under the two news types (store and corporate). Not only that, but I need to start with a header for the store news, then display all it's categories. This is followed by a header for the corporate news which in turn has all its categories under it as menu items.
<xsl:iftest="count(umbraco.library:GetXmlNodeById($parentPage)/descendant::*[@isDoc and not (self::Website) and not(self::Event) and string(naviHide) != '1']) > 0">
<xsl:for-eachselect="$currentPage/ancestor-or-self::*[@isDoc]/descendant-or-self::*[@isDoc] [umbraco.library:HasAccess(@id,@path) and string(naviHide) != '1' and (self::Nieuws or self::Pagina) and @level > 0]">
and this part should be like this:
<xsl:for-eachselect="$currentPage/ancestor-or-self::*[@isDoc]/*[@isDoc] [umbraco.library:HasAccess(@id,@path) and string(naviHide) != '1' and (self::Nieuws or self::Pagina) and @level > 0]">
we don't need to grab all nodes each time, we have for-each in child template, there are we would only traverse on first level of pages
Okay, removing the descendant-or-self on the first loop fixes it. It went from 5s on average to 0.5s difference between before- and after performing transformation.
Your second suggestion is noted, but I think the above will already be more than enough. Not sure if I will be given the time to restructure the entire sub item template to accomodate such a change =\
XSLT performance bottleneck
Hello,
One of our sites is experiences performance issues. Using the umbDebugShowTrace I have narrowed it down to a specific XSLT file. Now, I have checked it over, and the only parts that (to me anyway) seem like they could be the cause are the for-each loops we use. I have however, no idea of how to get the data I need with another (more optimized) Xpath expression. If someone could take a look at this that'd be great.
-Ferdy
The xslt:
Anyone?
Hi, Ferdy
Why do you use 'descendant-or-self' and 'ancestor-or-self'? at one time?
$currentPage/ancestor-or-self::*[@isDoc]/descendant-or-self::*[@isDoc]
[umbraco.library:HasAccess(@id,@path) and string(naviHide) != '1' and
(self::Nieuws or self::Pagina) and @level > 0]
descendant-or-self
Grabs all children nodes. I think it's bottleneck
It's to build up the menu correctly. No matter the current page I am on, I ALWAYS want to start from the top. So, using ancestor-or-self I go to the root, and then grab everything below it.
As I stated, I am pretty sure that is indeed the bottleneck. But I have no idea what would be a more efficient XPATH expression. Maybe I should add my node structure:
root
-website Dutch
- - store news
- - - categories
- - - - news posts
- - corporate news
- - - categories
- - - - news posts
- - page with a form
- - login page
- - acces denied page
-website Flemish
- - store news
- - - categories
- - - - news posts
- - corporate news
- - - categories
- - - - news posts
- - page with a form
- - login page
- - acces denied page
-website French
- - store news
- - - categories
- - - - news posts
- - corporate news
- - - categories
- - - - news posts
- - page with a form
- - login page
- - acces denied page
Whatever page I am on, I need to build a menu for the corresponding site (Dutch, Flemish or French). The menu items are the categories under the two news types (store and corporate). Not only that, but I need to start with a header for the store news, then display all it's categories. This is followed by a header for the corporate news which in turn has all its categories under it as menu items.
I hope I explained this clearly enough.
-Ferdy
Ferdy, could you give me link to your site ? ))
Afraid not, it's behind a login and contains sensitive information.
i think you shold remove this verification
and this part should be like this:
we don't need to grab all nodes each time, we have for-each in child template, there are we would only traverse on first level of pages
you could build menu without any descendant axes
why do you pass id into template ?
passing all item is more optimal, and you don't need do this operation
umbraco.library:GetXmlNodeById($parentPage)
Okay, removing the descendant-or-self on the first loop fixes it. It went from 5s on average to 0.5s difference between before- and after performing transformation.
Your second suggestion is noted, but I think the above will already be more than enough. Not sure if I will be given the time to restructure the entire sub item template to accomodate such a change =\
In any case, thanks!
-Ferdy
It's my pleasure.
We could cooperate) if you have a lot of umbraco projects )
Alex )
is working on a reply...