If I first load the organizations.xml into the database it takes 25 seconds to run (both before and after I run optimize).  If I run the extraction directly against the organizations.xml file on disk it only takes 7 seconds.

Is that to be expected?

Cheers,
-carl



On Jul 15, 2016, at 3:19 PM, Carl Leitner <litlfred@ibiblio.org> wrote:

Hi,
Here is a small of an example as I can get:

The source data set is organizations.xml.

There is a module that should be loaded extractor.xqm and then two scripts: extract_hieararchy.xq and extract_hieararchy-forked.xq

I appreciate your help.

Cheers,
-carl



On Jul 15, 2016, at 2:40 PM, Christian GrĂ¼n <christian.gruen@gmail.com> wrote:

declare function csd_bl:get_child_orgs($orgs,$org) {
let $org_id := $org/@entityID


return
  if (functx:all-whitespace($org_id))
  then ()
  else
    let $c_orgs := $orgs[./parent[@entityID = $org_id]]
    let $t0 := trace($org_id, "creating func for ")
    let $t1 := trace(count($c_orgs), " func checks children: ")
    let $c_org_funcs:=
      for $c_org in $c_orgs
      return function() {      ( trace($org_id, "executing child func for
") , $c_org, csd_bl:get_child_orgs($orgs,$c_org))}
    return xquery:fork-join($c_org_funcs)

(:
let $c_orgs :=
  if (functx:all-whitespace($org_id))
  then ()
  else $orgs[./parent[@entityID = $org_id]]
return
  for $c_org in $c_orgs
  let $t0 := trace($org_id, "processing children for ")
  return ($c_org,csd_bl:get_child_orgs($orgs,$c_org))
:)
};