We have a doctype with an index defined over three fields (obra, par and posPar). The following XQuery
for $a in input()/A
where $a/obra=398 and $a/par=557 and $a/posPar>=2
return $a
is very slow, while this one:
for $a in input()/A
where $a/obra=398 and $a/par=557 and $a/posPar = (2, 3, 4, 5, 6, 7, 8, 9)
return $a
is executed inmediately.
The problem is the “>” operand (or “>=” or “ge”) What’s the correct way to write the first XQuery?
I found another XQuery which executes efficiently. I just separated the criteria into two pieces. In one hand, the “equals” comparison, and in the other hand the “less than or equals” comparison. Just like this:
for $a in input()/A [posPar <= 9]
where $a/obra=398 and $a/par=557
return $a
I don’t know why Tamino likes this one but not the other one. But it works.