- From: Adam Retter <adam@exist-db.org>
- Date: Sun, 3 Jan 2016 21:32:11 +0000
- To: Christian Grün <christian.gruen@gmail.com>
- Cc: Michael Kay <mike@saxonica.com>, Public Joint XSLT XQuery XPath <public-xsl-query@w3.org>
Likewise, eXist also rewrites predicates to functions that perform index lookups where possible. We also attempt to rewrite where clauses to predicates if we can. On 3 January 2016 at 21:18, Christian Grün <christian.gruen@gmail.com> wrote: > In BaseX, we don’t change the order of existing predicates, mostly > because we didn’t stumble upon use cases in which reordering would > have led to big improvements (but I am totally sure that there are > such cases). > > What we do is to rewrite predicates to index expressions. We are > collecting predicates as candidates, and we are then choosing the > predicate with the highest selectivity: > > OLD: > //*[@type = 'address'][@id = 'id0'] > > NEW: > db:attribute('id0', 'id')/parent::*[@type = 'address'] > > Besides that, some where clauses are rewritten to predicates; in the > resulting expression, the original conditions will possibly be > executed in a different order: > > OLD: > for $a in 1 to 5 > for $b in 6 to 10 > where $b > 8 and $a > 3 > return $a + $b > > NEW: > for $a in (1 to 5)[. > 3] > for $b in (6 to 10)[. > 8] > return $a + $b > > Hope this helps, > Christian > > > > On Sun, Jan 3, 2016 at 9:56 PM, Michael Kay <mike@saxonica.com> wrote: >>> >>> eXist does not do much in the way of predicate reordering, currently >>> we suggest to users to put the most selective predicates first as we >>> evaluate them from left-to-right. In future, we could do more >>> intelligent reordering based on index statistics. >>> >> >> Aside: The optimum ordering, of course, is based on some combination of evaluation cost and selectivity. Saxon at the moment is doing a very rough - but still useful - estimate of evaluation cost, and is not attempting to take selectivity into account. >> >> Michael Kay >> -- Adam Retter eXist Developer { United Kingdom } adam@exist-db.org irc://irc.freenode.net/existdb
Received on Sunday, 3 January 2016 21:32:40 UTC