From: Wolfgang M. <wol...@ex...> - 2009-12-14 08:37:12
|
> I wonder whether eXist is currently optimizing xquery evaluations that use > positional predicates, or similar. I did implement shortcuts for the expensive axes: following and preceding. For example, LocationStep.getFollowing checks the property hasPositionalPredicate. If set to true, the method evaluates the predicate in advance to get its numeric value. This is then forwarded to the NodeSet method which calculates the join: return currentSet.selectFollowing(contextSet, position, contextId); We could apply similar optimizations to other axes, though their execution paths are more complex as you have more possibilities to choose from. However, my positional predicate optimization would only work for //elem[1], not //elem[position() = 1]. But I guess it would be possible to add a rewrite rule here to automatically simplify the expression. > collection("/")/ (//elem) [position() = (1 to 10)] Note that using subsequence instead of the predicate can be a lot faster sometimes. Wolfgang |