« Return to Thread: xquery nested loops

Re: xquery nested loops

by Adam Retter-3 :: Rate this Message:

Reply to Author | View in Thread


Have you set up appropriate indexes?


2008/4/25 Max Gaerber <mgaerber@...>:
Hi all,

I've got a question about performance tuning and nested xquery loops.
The data to be queried has several nesting levels, e.g.

<Publication Guid="a">
  <CategoryLink Guid="b" Ordering="1" Publish="true">
     <ProductInfoLink Guid="c" ...>
         <ProductItemLink Guid="d" ...>

A Publication has 5-20 Category elements with each about 50 ProductInfo
elements with each 2-10 ProductItem. Publication is only a "wrapper"
declaring some extra information whereas the "real" data of ProductInfo
etc. come from another collection.

There are three functions similar to the one below which loop through
the element set and create xhtml for display on a web site. The call to
local:ProductInfos($catLink) processes the next nesteing level and so
on. Now, the query is quite slow ( > 10 seconds ) even for small
Publications. Is there a better way to handle this sort of nesting?

declare function local:Categories($pub as node()) as node()? {
   <ul class="categories"> {
       for $catLink in $pub/CategoryLink
       let $cat := collection(/Syncrovet/Category)//Category[@Guid =
$catLink/@Guid]
       let $publish := ($catLink/@Publish = "true")
       order by $catLink/@Ordering
       return
       <li class="category {if ($publish) then "included" else
"excluded"}" id="{$catLink/@Guid}">
           <span class="name">{$cat/Name cast as xs:string}</span>
           { local:Tags($catLink) }
           { if ($publish) then local:ProductInfos($catLink) else () }
       </li>
   }</ul>
};

Thanks,

Max










-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open



--
Adam Retter

eXist Developer
{ England }
adam@...
irc://irc.freenode.net/existdb
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

 « Return to Thread: xquery nested loops

LightInTheBox - Buy quality products at wholesale price