Execution time / depends on variable position

Hello,
can anyone explain this?
query, where variable declaration is made “outside the loop”, takes 355 seconds to
execute and return value:

declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
let $part:=“NOVAK” ***
for $a in (
(for $zadeva in input()/Vpisnik
where ( tf:containsText( $zadeva/Udelezenci/Dolzniki/FizicnaOseba/Priimek, $part)
or tf:containsText( $zadeva/Udelezenci/Upniki/FizicnaOseba/Priimek, $part)
or tf:containsText( $zadeva/Udelezenci/Dolzniki/PravnaOseba/Naziv, $part)
or tf:containsText( $zadeva/Udelezenci/Upniki/PravnaOseba/Naziv, $part))
return

<inoid id={tf:getInoId( $zadeva)}>
{ $zadeva}

last()

)[position() < 11]
)
return $a

but look at this magic, … this query, where variable $part is defined inside the
“for” statement (marked with ***)
takes only 17mS !!! The size of collection is abt. 220.000 docs, each abt 3-6kB size, tekt and standard index on searced fields.

declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
for $a in ( let $part:=“NOVAK” ***
(for $zadeva in input()/Vpisnik
where ( tf:containsText( $zadeva/Udelezenci/Dolzniki/FizicnaOseba/Priimek, $part)
or tf:containsText( $zadeva/Udelezenci/Upniki/FizicnaOseba/Priimek, $part)
or tf:containsText( $zadeva/Udelezenci/Dolzniki/PravnaOseba/Naziv, $part)
or tf:containsText( $zadeva/Udelezenci/Upniki/PravnaOseba/Naziv, $part))
return

<inoid id={tf:getInoId( $zadeva)}>
{ $zadeva}

last()

)[position() < 11]
)
return $a

the query returns first ten inoid’s of cases, where persons have name or surname
containing $part.

Any comment?

Bye, Pavel

Hi Pavel,

i talked to the developers, interesting behaviour! It should take the same time, of course. Of course the faster one ;-). Looks like a bug.

Could you supply me with the example (schema, data and queries? I would like to pass this on to the developer, so this can be checked and hopefully fixed.

thanks,

Timm

Hello Timm,
i attached the schema to this post, i jope you have some tool to generate sample data.
The queryes ar those from the previous post. Hope this will help. If you need data, contact me via email.

bye, Pavel
Vpisnik.tsd (7.64 KB)