[MarkLogic Dev General] weird xpath behaviour
Szabolcs Illes
szabolcs.illes at ixxus.co.uk
Thu Feb 23 04:54:13 PST 2012
Hi,
I have seen this before, but came across again, so I thought ask this
time. Same/similar xquery but different results:
Version 1:
let $ids := /HorseRacingCard/Meeting[@country eq "England" and
AdvancedGoing]/@id
return (/HorseRacing/Meeting[@id = $ids] )[1]
returns expected results.
Version 2: Same as 1 but ids vatriable is just inlined
(/HorseRacing/Meeting[@id = /HorseRacingCard/Meeting[@country eq
"England" and AdvancedGoing]/@id ] )[1]
returns nothing [ slow, but that's expected: ]
Other than Version 2 is NOT optimal since the expression inside the
predicate is evaluated for each sequence item, I guess it should return
the same results.
Version 3:
(/HorseRacing/Meeting[@id =
fn:collection()/HorseRacingCard/Meeting[@country eq "England" and
AdvancedGoing]/@id ] )[1]
Returns expected results and it's fast, expression is only evaluated
once
Can someone shed some light why Version 2 is not returning any results?
Could it be a bug in the optimizer?
Thanks,
Szabolcs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120223/b5c8fb58/attachment-0001.html
More information about the General
mailing list