Hi!
we have two types of documents: A and B, each B document has an identifier that attach it to one A document. Each A document can have zero, one or more B documents attached.
We want to know how many A documents have one or more B documents attached, for it we use the following easy query:
count( for $a in input()/A
where (
for $b in input()/B
where ($b/@RefId=$a/@Id)
return $b
)
return $a
)
The atributtes “RefId” and “Id” are longs and have standard indexs.
The response time of this query is more than 30 seconds in a database with 20000 of A documents and 1000000 of B documents.
Otherwise the following similar query:
let $s := (for $a in input()/A
where (
for $b in input()/B
where ($b/@RefId=$a/@Id)
return $b
)
return $a
) return $s[position()<10]
is faster.
How can we improve the first query response time ?
Thanks in advanced
#API-Management#Tamino#webMethods