We got a review comment as follows. But I am not sure if replacing the
cts:search with xpath will help us with better performance. Also
avoiding xpath reverse-axes like parent, ancestor can give us better
performance. But we will not be able to get the required node without
the parent predicate. Please validate and let us know which is the
optimized way of performing the below operation.

Purpose of the xquery: we are searching for the tree node
corresponding to the given $folder-id inside the document $document

"Avoid usage of unnecessay search and parent:: operations like,
let $folder-id = "1234"
let $folder := cts:search(//metadata/id,cts:and-query(($folder-id,
cts:document-query($document))))/parent::metadata/parent::treenode

Instead try using predicates & xpath expressions,
let $doccontent := fn:doc("/ItemTree.xml")
let $treenode := $doccontent/itemtree/treenode[metadata/id = '1234']
return $treenode"

Sample XML Format:
<itemtree>
   <metadata/>
   <treenode>
      <metadata>
        <id>1234</id>
                  ….
     </metadata>
  </treenode>
  <treenode>
  </treenode>
</itemtree>

Thanks,
Radhika.
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to