Hmm. Looking at your query: 01: declare function extractor:get_child_orgs-forked($orgs,$org) { 02: for $org_id in $org/@id 03: for $c_orgs in $orgs[parent/@id = $org_id] 04: return xquery:fork-join( 05: for $c_org in $c_orgs 06: return function() { 07: $c_org, extractor:get_child_orgs-forked($orgs, $c_org) 08: } 09: ) 10: };
It seems that $c_orgs as defined in line 03 will be a single element. This means that when you get to line 05 we are looping over a single element and the enclosing fork-join will only be joining a single function/thread. Am I misreading that?
Cheers, -carl
On Jul 15, 2016, at 5:32 PM, Christian Grün christian.gruen@gmail.com wrote:
Hi Carl,
Running your version of the query does not exhaust memory as mine had, however I don’t see the CPU usage using more than one slightly more than available processor.
Your initial fork query was creating an endless loop. In the current one, I assume that only one function will be created for each xquery:fork-join call. Maybe you need to spend some more time on the question how your code could actually be forked in a recursive way at all?
What you probably want is a xquery:fork() function (without join), but we didn’t add such a function so far because it would be much more difficult to eventually join the results and find a good order.
Cheers Christian