Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • sun 403 posts 395 karma points
    Nov 27, 2012 @ 04:50
    sun
    0

    Add one useless line will make xslt run faster. Who can tell me why?

    The following xslt run very slow.It will take about 7 minutes.

    <xsl:variable name="tags" select="$currentPage/descendant-or-self::*[@isDoc and isTag='1']/@id"/>
    <xsl:variable name="nodes" select="$root//*[@isDoc and umbraco.library:Split(tags,',')//value=$tags]"/>

    But when I add one useless line, It will take no more than 1 minute.

    <xsl:variable name="tags" select="$currentPage/descendant-or-self::*[@isDoc and isTag='1']/@id"/>
    <xsl:value-of select="substring($tags,1,0)"/>
    <xsl:variable name="nodes" select="$root//*[@isDoc and umbraco.library:Split(tags,',')//value=$tags]"/>

    I hope someone could tell me why this happen.

  • sun 403 posts 395 karma points
    Nov 27, 2012 @ 11:08
    sun
    0

    Who can tell my why?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Nov 27, 2012 @ 13:13
    Chriztian Steinmeier
    1

    Hi sun,

    I can't tell you why, because it's almost certainly a quirk in the XSLT Processor that makes this happen.

    Does those two lines by themselves take 7 minutes to execute?

    You're not running this inside a for-each or accidentally using apply-templates on many more nodes than you think you are? (Just trying to find out where the bottleneck is).

    Anyway — I recently suggested using keys() to solve another performance related problem, which as it turned out, did exactly the trick - you may be able to use that to speed up your queries as well.

    With XPath, there's usually more than one way to do it, and some may be more efficient than others. Whenever possible, you should avoid the // (or descendant-or-self::) axis - starting from the topmost node that could possibly be selected can help a lot (if it's possible).

    /Chriztian

  • sun 403 posts 395 karma points
    Nov 27, 2012 @ 13:51
    sun
    0

    But How to use key()

Please Sign in or register to post replies

Write your reply to:

Draft