Database Reference
In-Depth Information
Index Types
Out of the box, eXist has a number of predefined index types available. This section
will tell you what they are and what they are used for. This is important, because you
have to choose the right tool for the job to get the best results. Configuring and using
these indexes is handled in the sections to come.
You can change the available index types (on the Java level), and even add your own.
However, that's an advanced subject and not discussed here. Please refer to the online
documentation if you want to know more about this.
Structural Index
eXist's structural index keeps track of the tree structure of nodes in all XML docu‐
ments stored in the database. It indexes all elements and attributes, so that when you
do a query like //title , it can quickly find all of the appropriate title elements.
Indexing is done with the qualified name (or QName ) of a node: both the namespace
and the local name are used.
The structural index also automatically indexes identifier attributes. These are
attributes called xml:id or attributes explicitly marked as of type ID in an attached
DTD.
The structural index is used for resolving nearly all XPath and XQuery expressions.
You can't configure or disable it, it is an integral part of eXist.
Range Indexes
Although the structural index allows eXist to find nodes by name quickly, it doesn't
do anything with the actual values of the nodes (except @xml:id ). So, a query
like //author[@name='erik'] will be able to find author elements that have a name
attribute quickly, but after that will still have to use brute force to compare the value
of the name attribute with 'erik' . When the database becomes large and the queries
more complex, performance will degrade rapidly.
Range indexes come to the rescue here: these indexes work on the values of nodes,
not their names. The optimizer will use them when you do a = , > , < , etc., comparison
in your XPath expression. They are also used for string comparisons within functions
like contains and even for regular expression lookups with the matches function.
Range indexes are also useful for nonstring comparisons. You can define the index to
treat the indexed value as, for instance, xs:double , xs:integer , or xs:dateTime (val‐
ues that cannot be cast as the specified type are ignored when the index is being cre‐
ated). This makes a query like //article[@price gt 100.0] with an xs:double
range index on the price attribute very efficient.
Search WWH ::




Custom Search