Mechanism for improving performance on XML over XML data using path subsetting

Information

  • Patent Application
  • 20060184551
  • Publication Number
    20060184551
  • Date Filed
    April 10, 2006
    18 years ago
  • Date Published
    August 17, 2006
    18 years ago
Abstract
Techniques are provided for indexing XML documents using path subsetting. According to one embodiment, a PATH table created for storing one row for each indexed node of the XML documents using user-defined criteria. The user-defined criteria are used to determine which nodes of XML documents to included in The PATH TABLE. The PATH table row for a node includes (1) information for locating the XML document that contains the node, (2) information that identifies the path of the node, and (3) information that identifies the position of the node within the hierarchical structure of the XML document that contains the node. Use of the user defined criteria is transparent to any query improves DML indexes overhead costs.
Description
FIELD OF THE INVENTION

The present invention relates to indexing XML data, and in particular, using path subsetting to more efficiently index XML data.


BACKGROUND OF THE INVENTION

The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.


Many database systems allow storage and querying of XML data. Though there are many evolving standards for querying XML, many of them include some variation of XPath. However, database systems are usually not optimized to handle XPath queries, and the query performance of the database systems leaves much to be desired. For example, a database system may satisfy an XPath query by performing a full scan of all documents. while a full scan of all documents can be used to satisfy all XPath queries, the implementation would be very slow due to the lack of indexes.


One solution to efficiently satisfy XPath queries involves providing indexes built over data stored as XML data (referred to herein as an “XML indexes”). Indexing information about XML documents allows for more efficient evaluating of Xpath expressions, by knowing how to specifically identify and locate elements in XML documents.


When the user submits a query involving XPaths (as predicate or fragment identifier), the user XPath is decomposed into a SQL query that accesses the XML index. Then the generated query typically performs a set of lookups using the XML index and merges their results appropriately.


As XML indexes are widely used in database systems for improving query prefomance the maintenance and overhead associated with the XML indexes is becoming increasing costly. Thus, there is always a trade-off between the index-maintenance overhead and the value added by the index. Therefore, there is a need to reduce the XML index maintenance overhead in order to effectively improve query performance.




BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements and in which:



FIG. 1 is a flowchart illustrating steps for determining whether a node is to be included in an XML index based on user specified path subsets; and



FIG. 2 is a block diagram of a system upon which the techniques described herein may be implemented.




DETAILED DESCRIPTION

In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of various embodiments of the invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present invention.


Functional Overview

A mechanism is provided for improving performance of storing and accessing XML documents by indexing only a subset of nodes in a collection of XML documents. A subset of nodes designated to be indexed or designated not to be indexed by a set of rules (e.g. path expressions) is referred herein to as a path subset. Path subsetting involves defining path subsets and indexing XML documents accordingly. Path subsetting may be used regardless of the format and data structures used to store the actual XML data (the “base structures”). For example, the actual XML data can reside in structures within or outside of a database managed by a DBMS (Database Management System), in any form, such as CLOB (character LOB storing the actual XML text), O-R (object-relational structured according to a schema, such as an XML schema), or BLOB (binary LOB storing some binary form of the XML).


The techniques described herein involve using a set of structures, which collectively constitute an index, for accessing XML data. In one embodiment, a mechanism is provided by which a user may specify rules that determine which subset of node in an XML document are to be indexed. Specifically, a user may register rules that expressly include certain XML paths, and/or rules that expressly exclude certain XML paths.


In one embodiment, the XML index that contains a user specified subset of nodes, results in one or more of the following benefits: (1) Improved search performance of XPath-based queries. (2) Allowing customizations of the values stored in the index. (3) the user specified nodes is transparent to any query. (4) Improved overhead costs associated with maintaining the index.


Hierarchy Nature of XML Data

XML documents are represented as hierarchy of nodes that reflects the XML documents hierarchical nature. The structure of an XML document establishes parent-child relationships between the nodes within the XML document. A hierarchy of nodes is composed of nodes at multiple levels. Each node at a level below the top level is a child node of one or more of the parent nodes at the level above. Nodes at the same level are siblings. A node that has no parent node linked to it is the root node, and a node that has no child nodes linked to it is a leaf node. The “path” for a node in an XML document reflects the series of parent-child links, starting from a “root” node, to arrive at the particular node.


For the purpose of explanation, consider the following XML document:

Pol.xml<PurchaseOrder><Reference>ABEL-20021127121040897PST</Reference><Actions><Action><User>ZLOTKEY</User></Action><Action><User>KING</User></Action></Actions>. . .</PurchaseOrder>


The path to the “User” node in po1.xml is /PurchaseOrder/Actions/Action/User, since the “User” node is a child of the “Action” node, the “Action” node is a child of the “Actions” node, and the “Actions” node is a child of the “PurchaseOrder” node. PurchaseOrder is the root node.


An XML index may be built on all of the paths within all of the indexed XML documents, or a subset of the paths within the indexed XML documents. Techniques for specifying which paths are index are described hereafter. The set of paths that are indexed by a particular XML index are referred to herein as the “indexed XML paths”.


The XML Index

According to one embodiment, an XML index is a domain index that improves the performance of queries that include Xpath-based predicates and/or Xpath-based fragment extraction. An XML index can be built, for example, over both XML Schema-based as well as schema-less XMLType columns which are stored either as CLOB or structured storage. In one embodiment, an XML index is a logical index that results from the cooperative use of a path index, a value index, and an order index.


The path index provides the mechanism to lookup fragments based on simple (navigational) path expressions. The value index provides the lookup based on value equality or range. There could be multiple secondary value indexes—one per datatype. The order index associates hierarchical ordering information with indexed nodes. The order index is used to determine parent-child, ancestor-descendant and sibling relationships between XML nodes.


The Path Table

According to one embodiment, a logical XML index includes a PATH table, and a set of secondary indexes. As mentioned above, each indexed XML document may include many indexed nodes. The PATH table contains one row per indexed node. For each indexed node, the PATH table row for the node contains various pieces of information associated with the node.


According to one embodiment, the information contained in the PATH table includes (1) a PATHID that indicates the path to the node, (2) “location data” for locating the fragment data for the node within the base structures, and (3) “hierarchy data” that indicates the position of the node within the structural hierarchy of the XML document that contains the node. Optionally, the PATH table may also contain value information for those nodes that are associated with values.


User Selection of which Paths to Index

According to one embodiment, a mechanism is provided by which a user may specify rules that determine which nodes in XML documents are to be indexed by an XML index. Specifically, a user may register rules that expressly include certain XML paths, and/or rules that expressly exclude certain XML paths.


According to one embodiment, the user can explicitly specify the set of nodes (subtrees) to be indexed—thereby omitting the remaining nodes from the PATH table. This is typically used to exclude fragments which are known to be useless from a query standpoint. By reducing the number of indexed nodes, the space usage and management efficiency of the XML index can be improved.


According to one embodiment, an initial registration of rules may occur at the time the XML index is created. In another embodiment of this invention, the user can provide registration of rules in the form of a list after the creation of the index. The user specifies the subset of nodes in XML documents to be index by providing a subset of XPaths. For purpose of illustration consider the following XML document:

Po2.xml<PurchaseOrder><Reference>SBELL-2002100912333601PDT</Reference><Actions><Action><User>SVOLLMAN</User></Action></Actions>. . .</PurchaseOrder>


Assume that the documents that are to be indexed are stored in a purchase Order table. If the user wants to index all the Lineitem elements and their children, and the purchase order reference number and requestor, then the following Create Index DDL (“data definition language”) statements can be issued to a DBMS:

CREATE INDEX POIndex1 ON purchaseOrderINDEXTYPE IS XML INDEXPARAMETERS ‘PATHS(/PurchaseOrder/LineItems//*, /PurchaseOrder/Reference)PATH TABLE POIndex_path_table’


In this example, the POIndex_path_table denotes the name of the table used by the domain index to store the index data. In the preceding example, the rules expressly include certain paths. All paths not expressly included by the rules will be excluded from the index.


If the XML document uses namespaces, then the index can be created with specified namespaced. For example, the Reference node belonged to a different namespace. The index can be created by:

CREATE INDEX POIndex1 ON purchaseOrderINDEXTYPE IS XML INDEXPARAMETERS ‘PATHS (/PurchaseOrder/LineItems//*,/PurchaseOrder/ipo:Reference NAMESPACEMAPPINGS(xmlns:ipo=http://www.example.com/IPO))PATH TABLE POIndex_path_table’


A user may also specify rules that expressly exclude paths. For example, to index all the paths of the documents except the Lineitem descriptions and the purchaseOrder actions, the following Create Index DDL is used to create the index:

CREATE INDEX POIndex2 ON purchaseOrderINDEXTYPE IS XML INDEX PARAMETERS ‘PATHS EXCLUDE/PurchaseOrder/LineItems/LineItem/Description,/PurchaseOrder/Actions)PATH TABLE POIndex_path_table2’


When an XML document is being indexed, each node in the XML document is matched against the user specified XPaths. If the node does not match any of the user specified paths, and no descendants of the node can match the any of the user specified paths, then the entire subtree rooted at the node is omitted from the index.


On the other hand, if the node matches any of the user specified paths, then one or more of the following will occur: (1) the fragment rooted at the node is added to the index. (2) All of the node's ancestors nodes are added to the index. (3) any namespace attributes within the ancestor element nodes are also added to the index. The addition of ancestors and namespace-mapping ensures that the index can be successfully used to construct node fragments of indexed nodes during a query.



FIG. 1 illustrates the steps for determining which nodes of an XML document to index. In step 102 a node is retrieved from an XML document that is being indexed. In step 104 the node is compared to the user defined path subsets. If the node matches any of the path subsets then in step 106 the node is added to the index. In step 108 the ancestors of the node are also added to the index. The ancestors of the node include all nodes along the path that lead to matched node. In step 110 any namespace attributes within the ancestor nodes are also added to the index.


If in step 104 it is determined that the node does not match any of the defined path subsets, then in step 112 a determination is made to establish whether there are any descendant nodes of the node that remain to be considered for indexing. If there are no descendant nodes remaining to be considered for indexing or none of the descendant nodes produced a match with any of the path subsets, then in step 114, the XML subtree rooted at the node is discarded from the indexes. However, if there are any remaining descendant nodes that produced a match with the path subsets or there are descendant nodes that still need to be compared to the path subsetting rules then the node and its subtree will not yet be discarded from the index. In this case, the next node from the XML document will be retrieved and the process repeats until all nodes have been considered for indexing.


Use of Wildcarding to Determine which Paths to Index

According to one embodiment, the user can include a wildecard symbol in the Xpath. The rule /PurchaseOrder/LineItems//* includes a wildcard symbol “*”. Consequently, the rule expressly includes the path/PurchaseOrder/LineItems and the path to all nodes that descend from the path/PurchaseOrder/LineItems. This is merely one example of how wildcards may be used in the rules. According to one embodiment, the path selection rule mechanism supports wildcards in any number of contexts. For example, the rule /nodex/*/nodey/nodez selects all paths that (1) descend from /nodex/ and (2) terminate in /nodey/nodez, regardless of the path between nodex and nodey/nodez.


Query Support in the Presence of Path-Subsetting

With the introduction of path-subsetting in the index, determining at query compilation time whether or not an index can be used to satisfy a query becomes more complicated. A determination by a DBMS of whether an index can be used not only depends on the base table to be accessed but also on whether the index may be used to find nodes within paths specified by the query.


In order to make this determination, at query compilation time, the XPath expressions within the query are checked against the one or more criteria used to create the index to determine whether evaluation of the XPath expression can be satisfied by the path subsets contained in the index. The one or more criteria may be described by metadata (“index metadata”) that defines the index. The index metadata is maintained by the DBMS and may be modified to describe the one or more criteria when, for example, the user registers path subsets by issuing DDL statements, such as those described earlier.


In the situation where one or more criteria used to created the index specifies a subset of paths to include in the index, the DBMS determines whether a given XPath expression is within a path subset covered by the index. In the situation where the one or more criteria used to create the index specifies a path subsets to exclude from the index, the DBMS determines whether the given XPath expression is not a subset of any of the excluded paths. This check determines whether an index can be used to satisfy an XPath query. The process of deciding to not use or use an index and/or using the index may be performed automatically and transparently, that is the process is performed, without users, applications, and even other software layers within the DBMS but outside of the query compilation layer, being aware of the process or being notified of it.


Hardware Overview


FIG. 2 is a block diagram that illustrates a computer system 200 upon which an embodiment of the invention may be implemented. Computer system 200 includes a bus 202 or other communication mechanism for communicating information, and a processor 204 coupled with bus 202 for processing information. Computer system 200 also includes a main memory 206, such as a random access memory (RAM) or other dynamic storage device, coupled to bus 202 for storing information and instructions to be executed by processor 204. Main memory 206 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 204. Computer system 200 further includes a read only memory (ROM) 208 or other static storage device coupled to bus 202 for storing static information and instructions for processor 204. A storage device 210, such as a magnetic disk or optical disk, is provided and coupled to bus 202 for storing information and instructions.


Computer system 200 may be coupled via bus 202 to a display 212, such as a cathode ray tube (CRT), for displaying information to a computer user. An input device 214, including alphanumeric and other keys, is coupled to bus 202 for communicating information and command selections to processor 204. Another type of user input device is cursor control 216, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 204 and for controlling cursor movement on display 212. This input device typically has two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), that allows the device to specify positions in a plane.


The invention is related to the use of computer system 200 for implementing the techniques described herein. According to one embodiment of the invention, those techniques are performed by computer system 200 in response to processor 204 executing one or more sequences of one or more instructions contained in main memory 206. Such instructions may be read into main memory 206 from another machine-readable medium, such as storage device 210. Execution of the sequences of instructions contained in main memory 206 causes processor 204 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions to implement the invention. Thus, embodiments of the invention are not limited to any specific combination of hardware circuitry and software.


The term “machine-readable medium” as used herein refers to any medium that participates in providing data that causes a machine to operation in a specific fashion. In an embodiment implemented using computer system 200, various machine-readable media are involved, for example, in providing instructions to processor 204 for execution. Such a medium may take many forms, including but not limited to, non-volatile media, volatile media, and transmission media. Non-volatile media includes, for example, optical or magnetic disks, such as storage device 210. Volatile media includes dynamic memory, such as main memory 206. Transmission media includes coaxial cables, copper wire and fiber optics, including the wires that comprise bus 202. Transmission media can also take the form of acoustic or light waves, such as those generated during radio-wave and infra-red data communications.


Common forms of machine-readable media include, for example, a floppy disk, a flexible disk, hard disk, magnetic tape, or any other magnetic medium, a CD-ROM, any other optical medium, punchcards, papertape, any other physical medium with patterns of holes, a RAM, a PROM, and EPROM, a FLASH-EPROM, any other memory chip or cartridge, a carrier wave as described hereinafter, or any other medium from which a computer can read.


Various forms of machine-readable media may be involved in carrying one or more sequences of one or more instructions to processor 204 for execution. For example, the instructions may initially be carried on a magnetic disk of a remote computer. The remote computer can load the instructions into its dynamic memory and send the instructions over a telephone line using a modem. A modem local to computer system 200 can receive the data on the telephone line and use an infra-red transmitter to convert the data to an infra-red signal. An infra-red detector can receive the data carried in the infra-red signal and appropriate circuitry can place the data on bus 202. Bus 202 carries the data to main memory 206, from which processor 204 retrieves and executes the instructions. The instructions received by main memory 206 may optionally be stored on storage device 210 either before or after execution by processor 204.


Computer system 200 also includes a communication interface 218 coupled to bus 202. Communication interface 218 provides a two-way data communication coupling to a network link 220 that is connected to a local network 222. For example, communication interface 218 may be an integrated services digital network (ISDN) card or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, communication interface 218 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN. Wireless links may also be implemented. In any such implementation, communication interface 218 sends and receives electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.


Network link 220 typically provides data communication through one or more networks to other data devices. For example, network link 220 may provide a connection through local network 222 to a host computer 224 or to data equipment operated by an Internet Service Provider (ISP) 226. ISP 226 in turn provides data communication services through the world wide packet data communication network now commonly referred to as the “Internet” 228. Local network 222 and Internet 228 both use electrical, electromagnetic or optical signals that carry digital data streams. The signals through the various networks and the signals on network link 220 and through communication interface 218, which carry the digital data to and from computer system 200, are exemplary forms of carrier waves transporting the information.


Computer system 200 can send messages and receive data, including program code, through the network(s), network link 220 and communication interface 218. In the Internet example, a server 230 might transmit a requested code for an application program through Internet 228, ISP 226, local network 222 and communication interface 218.


The received code may be executed by processor 204 as it is received, and/or stored in storage device 210, or other non-volatile storage for later execution. In this manner, computer system 200 may obtain application code in the form of a carrier wave.


In the foregoing specification, embodiments of the invention have been described with reference to numerous specific details that may vary from implementation to implementation. Thus, the sole and exclusive indicator of what is the invention, and is intended by the applicants to be the invention, is the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction. Any definitions expressly set forth herein for terms contained in such claims shall govern the meaning of such terms as used in the claims. Hence, no limitation, element, property, feature, advantage or attribute that is not expressly recited in a claim should limit the scope of such claim in any way. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.

Claims
  • 1. A method for indexing a collection of XML documents, comprising the steps of: receiving, a set of one or more criteria for identifying what portion of a structure of said XML collection of XML documents to index; and generating an index that indexes less than all nodes of said XML collection based on said set of one or more criteria.
  • 2. The method of claim 1 wherein the set of one or more criteria indicates nodes to index.
  • 3. The method of claim 1 wherein the set of one or more criteria indicates nodes not to index.
  • 4. The method of claim 1 further comprising the steps of: selecting a node from the nodes in an XML document; determining whether the node satisfies the set of one or more criteria; and indexing the node.
  • 5. The method of claim 4 wherein indexing the nodes includes indexing the node and ancestors of the node.
  • 6. The method of claim 1 wherein the set of one or more criteria indicates paths of nodes to index.
  • 7. The method of claim 1 wherein the set of one or more criteria indicates paths of nodes not to index.
  • 8. The method of claim 1 wherein the XML collection is maintained by a database system.
  • 9. The method of claim 1 wherein the one or more criteria is submitted by DDL statements.
  • 10. The method of claim 1 wherein the XML collection includes documents stored in a database in at least one of CLOB, object-relational structure, or BLOB.
  • 11. A method for executing a query over a collection of XML documents, comprising the steps of: based on one or more criteria, a DBMS maintaining an index to index less than all nodes within a collection of XML documents; the DBMS receiving a query; based on one or more criteria, the DBMS automatically determining whether the index may be used to evaluate a query.
  • 12. The method of claim 11, wherein said one or more criteria include at least one criterion that either: describes a set of nodes, within said collection of XML documents, to index within said index, and describes a set of node, in said collection of XML documents, to not index in said index.
  • 13. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 1.
  • 14. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 2.
  • 15. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 3.
  • 16. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 4.
  • 17. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 5.
  • 18. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 6.
  • 19. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 7.
  • 20. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 8.
  • 21. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 9.
  • 22. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 10.
  • 23. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 11.
  • 24. A computer-readable medium carrying one or more sequences of instructions which, when executed by one or more processors, causes the one or more processors to perform the method recited in claim 12.
RELATED APPLICATION

This application is a continuation-in-part of and claims priority to U.S. patent application Ser. No. 10/884,311, entitled Index For Accessing XML Data, filed on Jul. 2, 2004 by Sivasankaran Chandrasekara, the contents of which are herein incorporated by reference in their entirety for all purposes. This application is related to U.S. patent application Ser. No. ______, filed on ______ (Attorney Docket No. 50277-3051) entitled Isolalion for Applications Working on Shared XML Data, filed by Asha Tarachandani, the entire contents of which are herein incorporated by reference in their entirety for all purposes.

Continuation in Parts (1)
Number Date Country
Parent 10884311 Jul 2004 US
Child 11401613 Apr 2006 US