Hello,
I'm interested about BaseX technical details and its query exectution
techniques. BaseX uses structural joins such as XPath accelerator as a
main tree-join for a location step execution? In other words, do you use
some other type joins a as well (i.e. holistic joins such as TwigStack)?
I investigated the execution plans however I was not able to find any
information about indexes used by each operation. Can I observe it from
the plan like this:
<QueryPlan>
<GFLWOR>
<For var="$b">
<IterPath>
<DBNode name="xmark" pre="0"/>
<IterStep axis="child" test="*:site"/>
<IterStep axis="child" test="*:regions"/>
<IterStep axis="child" test="*"/>
<IterStep axis="child" test="*:item"/>
</IterPath>
</For>
<Let var="$k">
<AxisPath>
<VarRef>
<Var name="$b" id="0"/>
</VarRef>
<IterStep axis="child" test="name"/>
<IterStep axis="child" test="text()"/>
</AxisPath>
</Let>
<Order>
<OrderByExpr dir="ascending" empty="greatest">
<FNSimple name="zero-or-one(item)">
<AxisPath>
<VarRef>
<Var name="$b" id="0"/>
</VarRef>
<IterStep axis="child" test="location"/>
</AxisPath>
</FNSimple>
</OrderByExpr>
</Order>
<Return>
<CElem>
<QNm value="item" type="xs:QName"/>
<CAttr>
<QNm value="name" type="xs:QName"/>
<VarRef>
<Var name="$k" id="1"/>
</VarRef>
</CAttr>
<AxisPath>
<VarRef>
<Var name="$b" id="0"/>
</VarRef>
<IterStep axis="child" test="location"/>
<IterStep axis="child" test="text()"/>
</AxisPath>
</CElem>
</Return>
</GFLWOR>
</QueryPlan>
XQuery:
for $b in /site/regions//item
let $k := $b/name/text()
order by zero-or-one($b/location) ascending empty greatest
return <item name="{$k}">{$b/location/text()}</item>
Thank you for any response,
Radim