[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Performance degraded with grouping and sorting.

Subject: Re: Performance degraded with grouping and sorting.
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Sat, 30 Oct 2004 11:50:19 +0200
munchian method
Bhupendra, (and others,)

Why are you using a double for-each loop?

I would expect you use it to output a separator of any kind (title, hr, or anything else) between
the groups, but you aren't as far as I can see. In that case, I would expect it would be sufficient
to add a sort key on ACCT_NBR to group to that element. Note that the order of the sort keys
influences the result.

Also, I see you use things like *[name()=$paramSortKey], though only in the outer loop. Still, it
could improve performance to duplicate the sorting code and wrap things up in a choose, so that you
can replace the expression by just the element name.

Personally, I still prefer a multistep sorting and grouping algorithm. If you can assertain that
values are sorted already, grouping might become a lot easier in XSLT 1. I used Cocoon to build a
multistep process, where I first sort and later group. The grouping algoritms uses an index for
retrieving the first of a group, but not with the Munchian Method:

  <xsl:key name="first-group-values" match="item[not(preceding-sibling::*) or (@group !=
preceding-sibling::*[1]/@group)]" use="'all'" />
  <xsl:key name="values-by-group" match="item" use="@group" />

  <xsl:for-each select="key('first-group-values', 'all')">
    <!-- output separator -->
    <xsl:for-each select="key('values-by-group', @group)">
      <!-- output item -->
    </xsl:for-each>
  </xsl:for-each>

Note that I use a group attribute I determined in an earlier step to base the grouping on. This way,
the grouping algorithm doesn't change when I want to group on something else. (Separation of Concerns!)

Anyone who would like to do some performance tests on this?

Grtz,
Geert

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.