A DB2® XML index is a new type of index that you can create on a column of XML data in a DB2 table. The purpose of an XML index is to improve performance during queries on XML documents. In a relational index, index keys are composed of one or more specific table columns. In contrast to a relational index, an XML index uses a particular XML pattern expression to index paths and values in XML documents that are stored in a single XML column.
An XML pattern expression is an XPath expression that indicates the location of the nodes in the XML document and the attribute values that you want to use in the index. Only the nodes of a document that match the XML pattern are indexed.
For example, an XML pattern could be
This XML pattern would index all the rows in the table
that contain an XML document in the XML data column
in which the following facts are true:
A query with the predicate
match this index pattern, and could be chosen by
the optimizer if it offered a faster response.
Although you can include multiple columns in a relational index, you can specify only one column in an XML index. The column in an XML index must be the XML data type. You can specify only one XML pattern for an XML index. If you want to associate more than one XML pattern with a column of XML data, you can specify multiple XML indexes for that column.
An XML index uses the CREATE INDEX statement, which has been modified for XML support. Changes to the CREATE INDEX statement are described in your DB2 SQL documentation. You can also find the information in DB2 SQL documentation that is available through The SQL Reference for Cross-Platform Development Web page on developerWorks.
You develop an XML index in Visual Studio while you are defining the table that contains the XML index.