[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re:Re: How to improve the performance where a key
Hi Sun-fu, > You specially suggest me to consider using predicates such as: > > <xsl:variable name="MSource" select="$originalDoc/z:row"/> > <xsl:apply-templates select="$MSource[@OrderNo = $thisNo]" > mode="transDtl" /> > > instead of using key element, > > <xsl:for-each select="$originalDoc"> > <xsl:apply-templates select="key('TransNo',$thisNo)" > mode="transDtl"/> > </xsl:for-each> > > As matter of fact I have tried using predicates, however its > performance is much slower compared with that of using key table. So > I decide keep on using key function. Cool - you're absolutely right to test whether any sweeping statements about efficiency has a real effect in your particular case. I think the reason that you're getting such a marked increase in speed with the key is because in the code as you've given above, you're using it in a very worthwhile way. I was specifically talking about using a key *where the key was only used once on a particular document*. The case that I discussed was where you were using a key on an RTF that had just been created - you were creating several new RTFs (one for each OrderNo) and then using a key on each of them just once. In the case that you show above, on the other hand, you're using the key on $originalDoc. Here, the key is also used on $originalDoc prior to that, when you generate the $TransNoheading variable (set of unique z:row elements). And the key is also used multiple times within the xsl:for-each that's iterating over the OrderNos. So there, you're using a key on the same document *multiple* times - it's not surprising you get a marked increase in speed. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|