Hi Hans,

You might try below code and see if that helps in improving the
performance. You need to create range indexes on elements "j", "k", "d" and
"f".

BTW what values the elements "k" and "f" does contain? Is it numeric,
string or sentences ? If it contains para/sentences then you should think
some different way.

let $q1 := cts:and-query((cts:document-query("file1.xml"),
cts:element-range-query(xs:QName("j"), '=','123')))
for $key in cts:element-values(xs:QName("k"), (), (), $q1)
let $q2 := cts:and-query((cts:document-query("file2.xml"),
cts:element-range-query(xs:QName("d"), '=',$key)))
let $data-from-file-2 := cts:element-values(xs:QName("f"), (), (), $q2)
return
  <pre>
   $key => $data-from-file-2
  </pre>


Regards,
Indy

On Thu, Jun 23, 2016 at 10:23 AM, Hans Hübner <hans.hueb...@lambdawerk.com>
wrote:

> Hi,
>
> I have a beginner's question regarding indexing:  As far as I understand,
> MarkLogic indexes all data according to global indexing rules.  Thus, in
> general, all accesses to data should be "fast" when the universal index can
> be used.
>
> I am trying to combine data from two XML files into a report, and
> throughput is not sufficient.  I'm now looking for ways to improve the
> performance of my XQuery, either by adding indexes to MarkLogic or by
> improving the query so that it runs faster.  Here's what I have:
>
> for $key in doc("file1.xml")/a/b/c/d/e/f/g/h/i[j = 123]/k/text()
> let $data-from-file-2 := doc("file2.xml")/a/b[c/d = $key]/e/f/text()
> return
>   <pre>
>    $key => $data-from-file-2
>   </pre>
>
> Thus, I'm iterating over some subset of the nodes in file1.xml, selecting
> data from file2.xml for each of the nodes selected.  Both file1.xml and
> file2.xml are in a files residing in MarkLogic.  They have a pre-determined
> format and contain roughly 100,000 elements matching each of the two paths.
>
> It seems that the performance of the second of the two XPaths
> (doc("file2.xml")/a/b[c/d = $key]/e/f/text()) is most important.  Ideally,
> I would like this lookup to complete in under a millisecond, but it seems
> to need 75ms right now.
>
> Any help speeding this up would be greatly appreciated!
>
> Thanks,
> Hans
>
> --
> LambdaWerk GmbH
> Oranienburger Straße 87/89
> 10178 Berlin
> Phone: +49 30 555 7335 0
> Fax: +49 30 555 7335 99
>
> HRB 169991 B Amtsgericht Charlottenburg
> USt-ID: DE301399951
> Geschäftsführer:  Hans Hübner
>
> http://lambdawerk.com/
>
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to