Database Reference
In-Depth Information
ngram:wildcard-contains
This allows searching for substrings using a limited regular expression syntax.
Please refer to the function documentation for details.
General Optimization Tips
To round off this section, here are some general tips to help you make the most of
eXist's optimization techniques and indexes:
Prefer short paths
Because of the way the structural index works, queries like /a/b/c/d are slower
than //d .
Prefer XPath filters over FLWOR where clauses
Don't use for $n in //e where @id eq 1 . Rewrite this as for $n in //e[@id
eq 1] . eXist is much better at rewriting and optimizing predicates than where
clauses.
Reduce the search space as early as possible
If you have an XPath query with multiple predicates, like //Text[contains(.,
'eXist')][@id eq 1] , you should put the most restrictive one first. So in this
case (assuming identifiers are unique), //Text[@id eq 1][contains(.,
'eXist')] will most likely perform better.
Use multiple XPath predicates instead of the and operator
Writing //Text[@id eq 1][contains(., 'eXist')] is better than //Text[@id
eq 1 and contains(., 'eXist')] . The XQuery optimizer will try to do this
rewriting trick for you, but helping it by explicitly using multiple predicates
won't hurt.
Use a union operator instead of an or operator
An expression like //Text[@id eq 1 or contains(., 'eXist')] performs bet‐
ter when rewritten as //Text[@id eq 1] | //Text[contains(., 'eXist')] .
In all cases, of course, watch out for overdoing it. It's no use rewriting simple queries
that are already fast and/or work on small datasets. Also, try to remember the old
software engineering gem: maintaining code is usually more expensive than creating
it. Manually rewriting a query to squeeze out every last millisecond of performance
can easily obfuscate its meaning.
Debugging Indexes
Applying indexes can feel a bit unnerving: you've defined them and all seems to be
working, but is this really the case? Are your queries as efficient as you would like
them to be? This can be a hard thing to test, because during development you may
Search WWH ::




Custom Search