- From: Christian Grün <christian.gruen@gmail.com>
- Date: Sun, 3 Jan 2016 22:18:22 +0100
- To: Michael Kay <mike@saxonica.com>
- Cc: Adam Retter <adam@exist-db.org>, Public Joint XSLT XQuery XPath <public-xsl-query@w3.org>
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 >
Received on Sunday, 3 January 2016 21:19:09 UTC