XQuery performing question

Hi everybody,

I have the following doubt:

Let’s consider a XQuery retrieving documents from 2 different doctypes, like :

for $x in input()/doctype1, $y in input()/doctype2
where $x/property1 = $y/property2

return $x

This query will take a time, let’s suppose t1

Now let’s suppose to put the result into a variable $z

let $z:= for $x in input()/doctype1, $y in input()/doctype2
where $x/property1 = $y/property2

return $x

Now

for $k in $z return {$k/*} will take a time, let’s suppose t2

Is t2 < t1?

Is it right supposing that the last for is very quick because it does not perform a query but it only loops into a cursor?

In general, a for like the previous one does it have a light weight in a complex XQuery?

I look forward to hearing something from you.

Hi,

From my point of view the first variant will provide better performance, because both queries perform a join operation.
But the second one also does some result construction.
For the performance of both queries it is of highly relevance that proper indexing has been performed.
In certain cases you can also improve the performance by applying the “index-only” join method in Tamino.

Best Regards,

Thorsten Fiebig