Building sequence performance

Hello,
I do not know how to solve this; my collection is quite a big, abt. 250.000 documents,
this causes quite a big performance sensitivity.
But still i cannot understand this:
if i search the colllection this way:

declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
let $part:="DANEU"
for $case in input()/Registry
where ( tf:containsText( $case/Participants/Debtor/NaturalPerson/Name, $part))
return $case
i get an answer very fast a second or so, no problem.

But if i want to create a sequence out of the result so i could perform additional task on this sequence, something like this:

declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
let $part:="DANEU"
let $seq:=for $case in input()/Registry
where ( tf:containsText( $case/Participants/Debtor/NaturalPerson/Name, $part))
return $case
return $seq

the performance becomes terrible (more than 1 minute…)

Any hint?

Thanks, Pavel

Hello, i was playing around this a little bit more and what i found out:
this works if i do it this way:

declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
let $seq:=
(let $part:="DANEU"
for $case in input()/Registry
where ( tf:containsText( $case/Participants/Debtor/NaturalPerson/Name, $part))
return $case)
return $seq

The only difference is the location of the variable $part… somehow strange, well i am not an expert for the XQUERY syntax, but since parser does not complain, this might be a optimiser bug ?
bye, Pavel

I don’t know the Tamino optimizer well enough to be able to explain why one query should run faster than the other. Possibly one is using indexes and the other isn’t. Take a look at the “explain” pragma and see if this sheds any light on the execution strategy for the two queries, and try experimenting with other formulations until you can see what is causing the difference.

Another possibility is simply that the second query needs to allocate memory for the result sequence, or to do some copying of the documents whereas the second doesn’t. How big is the result sequence? And is the slow query precisely as you showed it, or is it (as you said) “something like” it?

Michael Kay