Am 12.06.2015 um 18:31 schrieb Christian Grün:
Hi Gioele,
It's usually a difficult task for the query compiler to rewrite nested
predicates. The following query may be evaluated faster (as I don't
have access to your data, I couldn't test it):
declare namespace tei='http://www.tei-c.org/ns/1.0';
/descendant::tei:orth
[text() = "arci"]
[ancestor-or-self::*
[@xml:lang][1][starts-with(@xml:lang, "san")]
]
/parent::tei:form
/(parent::tei:entry | parent::tei:re)
[parent::tei:body/parent::tei:text/parent::TEI
/parent::document-node()]
Hi Christian,
your query executes indeed much faster than mine: ~130 ms vs 600 ms.
My question is, would it be hard to detect a `[text() = X]` predicate
and turn it into a `db:text()` query as suggested by Fabrice?
In my case that optimization would turn
/descendant::tei:orth
[text() = "arci"]
[ancestor-or-self::*
[@xml:lang][1][starts-with(@xml:lang, "san")]
]
/parent::tei:form/parent::*[self::tei:entry | self::tei:re]
into
db:text('collection', 'arci')/
parent::tei:orth
[ancestor-or-self::*
[@xml:lang][1][(starts-with(@xml:lang, "san"))]
]
/parent::tei:form/parent::*[self::tei:entry or self::tei:re]
by hoisting the `text()` comparison and inverting the direction of the
axis, from `parent::` to `descendant::`.
It would be nice to be able to write to two queries that look almost the
same but one uses `text() = X` while the other uses `contains(text(),
X)` and have BaseX optimize them in different ways (db:text vs. full
text search). :)
If you want I can send you the data privately.
Regards,
--
Gioele Barabucci <[email protected].