Changes

Jump to navigation Jump to search
827 bytes added ,  13:18, 20 July 2018
==Path Index==
The path index (which is also called ''path summary'' or ''data guide'') stores all distinct paths of the documents in the database. It contains additional statistical information, such as the number of occurrence of a path, its distinct string values, and the minimum/maximum of numeric values. The maximum number of distinct values to store per name can be changed via {{Option|MAXCATS}}. Since {{Version|8.6}}, the distinct Distinct values are also stored for elements and attributes of numeric type.
Various queries will be evaluated much faster if an up-to-date path index is available (as can be observed when opening the [[GUI#Visualizations|Info View]]):
In various cases, existing index structures will not be utilized by the query optimizer. This is usually the case if the name of the database is not a static string (e.g., because it is bound to a variable or passed on as argument of a function call). Furthermore, several candidates for index rewritings may exist, and the query optimizer may decide for a rewriting that turns out to be suboptimal.
With {{Version|9.0}}, the {{Option|ENFORCEINDEX}} option was introduced, which allows you to enforce certain index rewritingscan be enforced. While the option can be globally enabled, it is usually better to supply it as [[XQuery Extensions#Pragmas|Pragma]]. Two examples:
* In the query below, 10 databases will be addressed. If it is known in advance that these databases contain an up-to-date text index, the index rewriting can be enforced as follows:
}]
[religions/text() = 'Protestant']
</pre>
 
With {{Version|9.1}}, the option can also be assigned to predicates with dynamic values. In the following example the comparison of the first comparison will be rewritten for index access. Without the pragma expression, the second comparison is preferred and chosen for the rewriting, because the statically known string allows for an exact cost estimation:
 
<pre class="brush:xquery">
for $name in ('Germany', 'Italy')
for $country in db:open('factbook')//country
where (# db:enforceindex #) { $country/name = $name }
where $country/religions/text() = 'Protestant'
return $country
</pre>
* The option should only be enabled if the addressed databases exist, have all required index structures and are up-to-date (otherwise, you will be given an error message).
* If you address the full-text index, and if you use non-default indexing options, you will have to specify them in your query (via {{Code|using stemming}}, {{Code|using language 'de'}}, etc).
* The enforcement of index rewritings gives you no guarantee that an index will be used. There are many expressions that cannot be rewritten for index access.
* If you have more than one enforce pragma in a single path expression, only the first will be considered.
=Changelog=
 
;Version 9.1
 
* Updated: [[#Enforce Rewritings|Enforce Rewritings]], support for comparisons with dynamic values.
;Version 9.0
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu