That's a good hint: Some optimizations still need to be tweaked to support namespaces [1]. You’ll be safe if you include the explicit text step.
[1] https://github.com/BaseXdb/basex/issues/1763
Matthew Dziuban mrdziuban@gmail.com schrieb am Fr., 29. Apr. 2022, 21:00:
As I was trying to come up with a simple example to reproduce it I rediscovered that the top-level <data> element specifies an XML namespace, apologies I failed to mention that initially. Would that affect whether the index is used or not?
I'm able to reproduce by loading this data into a new database named ElementsTest:
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <element><id>1</id></element> </data>
And then running this query:
for $x in db:open('ElementsTest')/data/element where $x/id = '1' return $x/id
The GUI shows the following as the optimized query:
db:open-pre("ElementsTest", 0)/data/element[(id = "1")]/id