On Sat, Apr 16, 2022 at 02:16:23PM +0200, Markus Elfring scripsit:
It is supported to specify a fixed number of information sources for a for clause. https://www.w3.org/TR/xquery-31/#id-xquery-for-clause
I imagine that the selection of for bindings can occasionally vary so much and might become so big that it would be needed to construct FLWOR expressions by more sophisticated data structures.
A for clause will take any sequence as the binding sequence, and the order of clauses in a FLOWR expression comes down to "ends with a return clause" for most practical purposes.
let $interesting as item()* := some expression for $this in $interesting ....
Works as a pattern.
So does
let $interesting.... where some test for $this in interesting ....
Generally speaking, the way to cope with size is by using references. That's either indexes or by writing queries that find the interesting node once and thereafter use references. It's not immediately obvious that this is what maps are for, but if you construct a map and the value is a DB node, the map key for that value functions as a pointer to that value. You can then iterate on the map keys.
In BaseX, the performance benefit from doing this can be a couple-three orders of magnitude.