From: Michael S. <so...@if...> - 2009-12-15 13:01:08
|
Thanks for your answer, Wolfgang - that's just the sort of thing I was wondering about. I walked through the logic in selectFollowing: I can see it would be possible, but complicated to implement something similar for other axes and for a somewhat more complex predicate (compare position against a constant sequence). Maybe that's worth doing - I'm not sure though. Frankly the main cases I am interested in are not really axis selections, but ordered sequences of nodes from different documents where the ordering is determined either by a value (that may be indexed) or by the lucene score. These correspond to searches in our applications where the results are ordered alphabetically by title, or by relevance. So I asked the other question mostly just to try and understand better what kind of optimization strategies you are using. I'll keep looking and let you know if I have anything helpful to offer! I'm also curious about the answer to Joe's question re: the difference between subsequence and predicate: if you have a moment could you elucidate? -Mike Also: my e-mails to this list seem to need moderation. If you'd rather not be bothered about that, I could move this discussion over to the exist-open list? > -----Original Message----- > From: Wolfgang Meier [mailto:wol...@ex...] > Sent: Monday, December 14, 2009 3:37 AM > To: Michael Sokolov > Cc: exi...@li... > Subject: Re: [Exist-development] optimizing positional > predicates for fast paging > > > 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 > |