Hi Gioele, Queries with positional predicates such as the one that I posted in my last mail (in private, attached below) are now optimized as well.
Best, Christian [1] http://files.basex.org/releases/latest/ On Mon, Jun 15, 2015 at 1:09 PM, Christian Grün <[email protected]> wrote: > Hi Gioele, > >> I had a look at the info view but I fail to understand whether it is >> optimized or not. What should I look at? Sometimes I see a "Optimized Query" >> section, but it is not present for these two queries. > > I see. Yes, this means that the query is not rewritten. Instead, this > is one is optimized for index access, as the query info (and, > obviously, in this case the execution time) will show you: > > /descendant::tei:orth[text() = "arci"] > > I noticed that the query is not rewritten because of the positional > predicate (which are generally brain twisters in XQuery). Things look > better with the following query (but it may yield other results): > > /descendant::tei:orth > [text() = "arci"] > [ancestor-or-self::* > [@xml:lang][starts-with(@xml:lang, "san")] > ] > /parent::tei:form/parent::*[self::tei:entry or self::tei:re] > > The following query should take advantage of the index: > > for $n in /descendant::tei:orth[text() = "arci"] > where $n/ancestor-or-self::* > [@xml:lang][1][starts-with(@xml:lang, "san")] > return $n/parent::tei:form/parent::* > [self::tei:entry or self::tei:re] > > Best, > Christian

