Using the factbook.xml database and a recent 7.1.2 beta, I am hitting some performance problems. To debug I have been trying some expressions in the GUI window. The goal is given a country id, get the capital. The examples use Albania ="f0_136"
let $id:="f0_136"
let $cap:=//country[@id=$id]/@capital
return //city[@id=$cap]
------result------------
<city id="f0_1461" country="f0_136" longitude="10.7" latitude="46.2">
<name>Tirane</name>
<population year="87">192000</population>
</city>
Time: 0.7ms
Very nice. Sadly my code is not doing it like this! ( the xpath is being generated from some data description xml I have created)
If I try in the GUI some Xpath variations they produce wildly different execution times
let $id:="f0_136"
return //city[@id=(//country[@id=$id]/@capital)]
26144ms
let $id:="f0_136"
return //city[@id=//country[@id=$id]/@capital]
25157ms
let $id:="f0_136"
return (//city)[@id=(//country[@id=$id]/@capital)]
550ms
let $id:="f0_136"
return (//city)[@id=((//country)[@id=$id]/@capital)]
6087ms
I was expecting all these to perform about the same. They all produce the same result.
/Andy