Reputation: 71
I want to improve the performance of my xslt 2.0. I use saxon-sa 9.0.0.5 as xslt processor. With the help of profiling, I zeroed into the bottleneck. Here is my bottleneck piece of code extracted
<xsl:variable name="party" select="/drawdownInventoryAndEventNotification/party"/>
-- approximately 500 parties
<xsl:apply-templates select="$party[@id = ($abc/@id union $xyz)]"/>
-- union is producing a sequence of about 20k items. Comparison of this 20k items to party@id is cause for the performance.
Thanks in advance for your valuable solutions / workarounds.
Upvotes: 2
Views: 74
Reputation: 163458
Using a key as suggested by @MartinHonnen would be my first reaction, and is worth trying, but it's possible it might not help much, because (a) although Saxon-SA 9.0 is a long time ago and my recollection might be faulty, I think the Saxon optimizer should introduce the key automatically, and (b) the problem may be in evaluating the union.
Are there many duplicates in the result of the union? If so, applying distinct-values() to eliminate the duplicates might help.
If you want to package it up in a form that we can run, we'll be happy to take a look at it. But only if you're prepared to move forward to a more recent software release.
Upvotes: 1
Reputation: 167706
Try to define a key <xsl:key name="party-by-id" match="/drawdownInventoryAndEventNotification/party" use="@id"/>
, then replace <xsl:apply-templates select="$party[@id = ($abc/@id union $xyz)]"/>
with <xsl:apply-templates select="key('party-by-id', $abc/@id union $xyz)"/>
.
Upvotes: 2