US20130080441A1 - Index selection for xml database systems - Google Patents

Index selection for xml database systems Download PDF

Info

Publication number
US20130080441A1
US20130080441A1 US13/536,343 US201213536343A US2013080441A1 US 20130080441 A1 US20130080441 A1 US 20130080441A1 US 201213536343 A US201213536343 A US 201213536343A US 2013080441 A1 US2013080441 A1 US 2013080441A1
Authority
US
United States
Prior art keywords
candidate path
expressions
index
expression
candidate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
US13/536,343
Other versions
US9594783B2 (en
Inventor
Ashraf Aboulnaga
Andrey Balmin
Kevin S. Beyer
Iman Elghandour
Fei Yen Chiang
Daniele Costante Zilio
Calisto Paul Zuzarte
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
International Business Machines Corp
Original Assignee
International Business Machines Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by International Business Machines Corp filed Critical International Business Machines Corp
Priority to US13/536,343 priority Critical patent/US9594783B2/en
Publication of US20130080441A1 publication Critical patent/US20130080441A1/en
Assigned to INTERNATIONAL BUSINESS MACHINES CORPORATION reassignment INTERNATIONAL BUSINESS MACHINES CORPORATION ASSIGNMENT OF ASSIGNORS INTEREST (SEE DOCUMENT FOR DETAILS). Assignors: ZILIO, DANIELE COSTANTE
Application granted granted Critical
Publication of US9594783B2 publication Critical patent/US9594783B2/en
Expired - Fee Related legal-status Critical Current
Adjusted expiration legal-status Critical

Links

Images

Classifications

    • G06F17/30312
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/81Indexing, e.g. XML tags; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/83Querying
    • G06F16/835Query processing
    • G06F16/8365Query optimisation

Definitions

  • the present invention relates generally to selection of indexes for XML database systems.
  • XML database systems are expected to handle increasingly complex queries over increasingly large and highly structured XML databases. Having the correct indexes can significantly improve performance of such queries. Although some XML database systems will employ indexes to improve query performance, deciding which indexes to create may be problematic.
  • a method, computer-implemented system, and computer program product for creating indexes over XML data managed by a database system are provided.
  • the method, computer-implemented system, and computer program product provide for receiving a workload for the XML data, the workload including one or more database statements, utilizing an optimizer of the database system to enumerate a set of one or more path expressions by creating a virtual universal index based on the workload received and matching a path expression to the virtual universal index, and recommending one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data.
  • FIG. 1 depicts a process for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 2 illustrates a system for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 3 shows a process for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 4 depicts architecture of a system for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 5 illustrates a table listing enumerated candidate index patterns for sample queries according to an implementation of the invention.
  • FIG. 6 shows an example of an expression tree representing a path expression.
  • FIG. 7 depicts a table with a set of rules used by an algorithm according to an implementation of the invention.
  • FIG. 8 illustrates a table listing generalized candidate index patterns for sample queries according to an implementation of the invention.
  • FIG. 9 shows a block diagram of a data processing system with which implementations of the invention can be implemented.
  • the present invention generally relates to selection of indexes for XML database systems.
  • the following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements.
  • Various modifications to the described embodiments and the generic principles and features described herein will be readily apparent to those skilled in the art.
  • the present invention is not intended to be limited to the embodiments shown but is to be accorded the widest scope consistent with the principles and features described herein.
  • indexes are an important part of any database system design as indexes can significantly impact workload performance by enabling quicker and more efficient access to data. Determining which indexes are suitable for XML database systems is now increasingly important because XML is becoming the standard language in which data are represented and exchanged.
  • XML which stands for eXtensible Markup Language
  • XML database systems may be systems that only support XML data or may be systems that support XML and other types of data (e.g., relational data).
  • Index selection for other types of data, such as relational data differs from index selection for XML data because with XML data, a variety of index types (e.g., structural, value, and so forth) may be needed. Additionally, the structure of XML data may be more complex.
  • XML indexes also differ from regular indexes in that not only do they define the data type and column to index but also an XML pattern within the XML column to index for values indexes.
  • an XML database system may allow an index to be created for a portion of an XML document that matches an index pattern.
  • the index pattern may be expressed as a path expression (e.g., ‘//people/person/homepage’) such that only the XML elements reachable by the path expression are included in the index.
  • Partial indexing leads to smaller indexes that only include portion(s) of document(s) that are useful. Index maintenance is also more efficient with partial indexing. Additionally, index lookup performance is improved over indexes on whole document(s). Selection of indexes, however, is further complicated because not only do decisions need to be made as to which type of indexes to create and which documents to index, decisions will also have to be made as to which portions of each document to index.
  • FIG. 1 Depicted in FIG. 1 is a process 100 for selecting indexes to be created over XML data according to an implementation of the invention.
  • a workload for the XML data is received.
  • the workload includes one or more database statements.
  • Database statements may be expressed using XQuery, which is a query language that can be used to query XML data.
  • an optimizer is utilized to recommend a set of one or more path expressions to be used to create one or more indexes over the XML data based on the workload received.
  • Path expressions may be expressed using XPath, which is a language that can be used to address parts of an XML document.
  • Process 100 may include additional process blocks (not shown) of creating one or more indexes over the XML data using the set of one or more path expressions recommended and storing the one or more indexes over the XML data in memory or on disk.
  • An index may be viewed as providing an efficient mapping from one or more path expressions to XML elements that are reachable by the one or more path expressions.
  • at least one of the one or more indexes to be created over the XML data is a partial index.
  • Indexes that are created may be structural indexes or value indexes.
  • Structural indexes help in speeding up navigation through hierarchical structure of XML data and answering queries, such as, “/Security/Symbol”, which is requesting all security symbols.
  • recommendation of the set of one or more path expressions is also based on one or more system constraints (e.g., disk space, schema, and so forth).
  • Recommendation of the set of one or more path expressions may also take into account increased costs associated with update, delete, and insert (UDI) statements when one or more indexes are created using the set of one or more path expressions recommended.
  • system constraints e.g., disk space, schema, and so forth.
  • FIG. 2 illustrates a system 200 for selecting indexes to be created over XML data according to an implementation of the invention.
  • System 200 includes a database 202 that stores the XML data.
  • system 200 includes an optimizer 204 in communication with database 202 .
  • Optimizer 204 optimizes database statements seeking access to the XML data stored in database 202 .
  • An index advisor 206 that is in communication with optimizer 204 is also included in system 200 .
  • index advisor 206 uses optimizer 204 to recommend a set of one or more path expressions 210 based on the workload 208 received by index advisor 206 .
  • the set of one or more path expressions 210 can be used to create one or more indexes (not shown) over the XML data stored in database 202 .
  • Shown in FIG. 3 is a process 300 for selecting indexes to be created over XML data managed by a database system according to an implementation of the invention.
  • a workload for the XML data which includes one or more database statements, is received.
  • an optimizer of the database system is utilized to enumerate a plurality of candidate path expressions based on the workload received.
  • the plurality of candidate path expressions enumerated is generalized to generate additional candidate path expressions.
  • the optimizer is utilized to estimate a benefit associated with each candidate path expression in relation to the workload received. For each candidate path expression, the optimizer is also utilized to estimate a size of an index to be created using the respective candidate path expression at 310 . At 312 , one or more candidate path expressions are recommended for use in creating one or more indexes over the XML data.
  • Recommendation of the one or more candidate path expressions is based on at least one of a system constraint, the estimated size of the index to be created using each candidate path expression, and the estimated benefit associated with each candidate path expression.
  • the recommendation may be based on interaction between the one or more candidate path expressions.
  • FIG. 4 depicts architecture of a system 400 for selecting indexes to be created over XML data according to an implementation of the invention.
  • System 400 includes an index advisor 402 that is in communication with an optimizer 404 .
  • Optimizer 404 has two modes, an enumerate indexes mode and an evaluate indexes mode.
  • enumerate indexes mode optimizer 404 takes a query and generates index patterns (e.g., path expressions) that can be useful to the query. The index patterns can then be used to create indexes.
  • index patterns e.g., path expressions
  • optimizer 404 simulates an index configuration based on one or more index patterns and estimates the cost of a query under the index configuration. This mode also estimates the statistics for simulated indexes to allow the costing to be more accurate.
  • index advisor 402 receives a query workload. For every query in the workload, optimizer 404 is relied upon to enumerate a set of candidate index patterns useful for the particular query, which can be used to create indexes. Next, index advisor 402 expands the set of candidate index patterns generated by optimizer 404 to include more general index patterns, each of which can potentially benefit multiple queries, either from the workload or from other workloads.
  • index recommendation process is described in more detail below in conjunction with the following sample queries:
  • the optimizer when an optimizer is used for index pattern enumeration, the optimizer creates and uses virtual indexes during the enumeration process.
  • Virtual indexes are hypothetical indexes that are added to a database catalog and to all internal data structures of the optimizer, but are not physically created in memory or on disk and no data is inserted into them. Virtual indexes cannot be used for query execution.
  • the optimizer uses virtual indexes in conjunction with its index matching capabilities to assist an index advisor to enumerate candidate index patterns, which in turn, can be used to create candidate indexes.
  • the optimizer decides, for a current query being optimized, which of the available indexes can be used by the current query, and how can they be used (e.g., for which predicates in the query). Predicates matched to indexes can then be used as candidate index patterns.
  • indexes to be created based on the candidate index patterns enumerated by the index advisor are assured to be ones that can actually be matched and used by the optimizer.
  • functionality of index matching in the optimizer is leveraged so that there will be no need to replicate this functionality outside of the optimizer.
  • one or more virtual universal or general indexes may be created over XML data (e.g., //* for a given XML column and data type, //@ for a given attribute, and so forth). These virtual general indexes virtually index all elements the XML data and hence can be matched with any path expression that can be answered using the index.
  • the optimizer can then optimize a query with these virtual general indexes in place. After index matching, all path expressions in the query that are matched with a virtual general index are collected.
  • each candidate path expression and corresponding information are recorded (e.g., in memory, on disk, or somewhere else). Illustrated in FIG. 5 is a table 500 that lists enumerated candidate index patterns for the two sample queries Q1 and Q2.
  • the candidate enumeration process allows the index matching capabilities of the optimizer to be leveraged, as well as, its query parsing, type checking, and query rewriting capabilities.
  • the index advisor can support any query language supported by the optimizer (e.g., XQuery, SQL/XML, and so forth).
  • the index advisor can also support any type checks or type casts that the optimizer performs when using an index, and it can enumerate any indexes that are only exposed by query rewrites in the optimizer.
  • a different virtual universal index may be created for each element, attribute, and/or data type in the XML data. Rather than creating a virtual universal index for each element, attribute, and/or data type in the XML data, a virtual universal index may be created for each element, attribute, and/or data type involved in a particular query being optimized.
  • the index advisor sends each query in a workload to the optimizer for optimization. Index patterns chosen by the optimizer for each query are then added to a set of candidate index patterns that will be considered while searching for an optimal index configuration for the XML data.
  • Candidate index patterns enumerated above are specific to individual queries as an optimizer identifies patterns specific to each query that could benefit from an index. The optimizer, however, may not be able to identify common patterns across queries. Common patterns can lead to more general indexes that can benefit multiple queries in a current workload and in future workloads.
  • candidate index patterns enumerated by the optimizer are expanded by applying a set of generalization rules that create more general candidate index patterns useful to multiple queries from the candidate index patterns that are specific to individual queries. For example, as shown in table 500 of FIG. 5 , path expressions “/Security/Symbol” and “/Security/SecInfo/Sector” are identified by the optimizer as candidates for indexing. Based on these two path expressions, an additional and more general candidate path expression “/Security//*” can be generated.
  • the additional candidate path expression covers the original two candidate path expressions as well as other path expressions that could potentially exist in the XML data, such as “/Security//Industry”.
  • the index advisor can recommend the additional candidate path expression as an alternative to or in addition to the two original candidate path expressions.
  • the new candidate may have a size that is greater than the total size of the two original candidates as it covers more paths, it can potentially be useful for queries beyond those that are covered by the other two.
  • the path expression may be represented as an expression tree, such as an XPS tree (XPath Step tree).
  • An XPS tree is composed of labeled nodes. Each node is labeled with its navigation axis and its node test, where the navigation axis is the special axis root or one of: child, descendant, or attribute.
  • the test can be either a name test or a wildcard test.
  • FIG. 6 shows an example of an expression tree 600 representing a path expression.
  • the node ‘Security’ has both an equality predicate child and a next step child.
  • Path expressions may contain both navigational and predicate branching.
  • Navigation can contain label wildcards, “*”, child axis navigation, “/”, and descendant navigation, “//”.
  • Tree representation can be obtained by parsing path expressions. After generalization, a generalized tree can be traversed to obtain a corresponding path expression.
  • Generalized candidate path expressions can be found by iteratively applying several generalization rules to each pair of candidate path expressions enumerated for specific queries and to resulting generalized candidate path expressions. This process may continue until no new generalized path expressions can be generated.
  • the rules consider two path expressions concurrently and try to find common path nodes between the two paths and capture the commonality in a new generalized path expression(s).
  • the new generalized path expression(s) are then added to candidate path expressions already enumerated.
  • ‘generalizeXPworkload’ algorithm data type, table name, and column name of the pairs are checked for compatibility. Data type, however, may not be checked for path expressions to be used to create structural indexes. After checking data type, table name, and column name, another algorithm called ‘generalizedStep’ is called for every qualifying pair.
  • the ‘generalizedStep’ algorithm applies generalization rules to a pair of path expressions to find all common sub-expressions. Variable p i is used to refer to the root of a subtree in a path expression currently being generalized and variable genXPath is used to refer to an expression tree of a generalized path expression being generated.
  • paths are divided into two parts: a last step that represents nodes being indexed and a path leading to the last step.
  • a predicate occurs in the middle of a path expression, it is generalized to include all nodes, not just the ones qualified by the predicate.
  • the ‘generalizedStep’ algorithm accepts as input genXPath, p 1 , p 2 .
  • root nodes f 1 and f 2 of trees p 1 and p 2 root nodes f 1 and f 2 are checked to see whether they have the same axis and name test information. If so, the newly generated node retains the same axis and name test information as f 1 and f 2 . If not, a generalized form for the axis and found and the name test is replaced with a wildcard label. The new node is then appended to the genXPath tree currently being generated and passed along with p 1 and p 2 to the ‘generalizedComp’ algorithm to process the rest of the expressions. The list of generated trees returned from the ‘generalizedComp’ algorithm is passed back to the ‘generalizeXPworkload’ algorithm to be appended to list of candidates.
  • the ‘generalizeComp’ algorithm plays the role of traversing the trees by advancing the tree pointers of p 1 and p 2 according to a set of rules.
  • FIG. 7 Depicted in FIG. 7 is a table 700 with a set of rules used by the ‘generalizedComp’ algorithm according to an implementation of the invention.
  • the set of rules are designed to generate candidates that are as general as possible. In some cases, several choices may be considered in parallel, and hence more than one genXPath may be found and a list of all of these genXPaths is returned.
  • to generalize a pair of XPS trees begin at root nodes of both trees and proceed by advancing their pointers. At each step, attempt is made to generalize the nodes currently being processed. For example, to generalize candidates C1: /Security/Symbol and C2: /Security/SecInfo/*/Sector from table 500 in FIG. 5 , an initial call is made to generalizedStep(null, /Security/Symbol, /Security/SecInfo/*/Sector).
  • the ‘generalizedStep’ algorithm looks at the nodes /Security in both paths and recognizes that they have the same name tests, therefore it creates a node with a /Security name test and appends it to a genXPath being produced. It then calls generalizedComp(/Security, /Security/Symbol, /Security/SecInfo/*/Sector) to complete processing these expressions.
  • Rule 4 in table 700 in FIG. 7 applies, and the pointer of the second expression is advanced until /Sector is reached. Then generalizedStep (/Security/*, /Symbol, //Sector) is called. As nodes /Symbol and /Sector have different name tests, a new node with a wildcard name test is appended to the genXPath. This time when generalizedComp(/Security/*/*, /Symbol, /Sector) is called, Rule 1 in table 700 is applied and the expression /Security//* is returned after processing the consecutive wildcard nodes. Finally, the list of candidates in table 500 can be extended to include candidate C4 in a table 800 illustrated in FIG. 8 .
  • multiple generalized trees can be generated. For example, running the generalization algorithm on two expressions /a/b/c/@d and /c/a/b/@d, Rule 5 in table 700 will be applied and more than one common sub-expression may be found for the two expressions. Hence, two new expressions will be returned to be added to the candidate set: //a/b//@d and //c//@d.
  • the generalization step can also be used to check if a candidate path expression is a generalization of another. If the generalization of a pair of path expressions p 1 and p 2 is equal to one of them, say p 1 , then p 1 is a generalization of p 2 , then the fact that queries that benefit from p 2 will also benefit from p 1 can be recorded.
  • Some path expressions might not be generalized with any other path expression.
  • An example of this is candidate C3 in table 500 of FIG. 5 .
  • a technique that predicts the existence of other expressions similar to a candidate can be used.
  • the technique replaces a last non-* navigation step in a candidate path expression with a * navigation step.
  • the path C3 in table 500 can be generalized into /Security/*.
  • a more comprehensive approach may consult the data to determine the usefulness of such a generalization and recommend other generalizations.
  • An optimizer can be used by an index advisor to estimate the benefit to a workload of having a particular index configuration.
  • Virtual indexes can be created using candidate path expressions and used to estimate the cost of a workload with the virtual indexes in place. These virtual indexes can be included with other existing real indexes when performing index matching to find candidate indexes and when determining an execution plan for a query.
  • the optimizer After optimizing a query using virtual indexes, the optimizer returns a set of indexes used along with statistics and cost information. The information is used by the index advisor to determine the benefit of using an index or a configuration consisting of multiple indexes.
  • the optimizer While finding an execution plan in the presence of one or more virtual indexes, the optimizer will need statistics about these virtual indexes to get better cost estimates. Some of these statistics are data statistics, such as the distinct path expressions being indexed and their frequencies, while others are index statistics, such as a number of disk pages occupied by the index. All the necessary data statistics may be collected using an optimizer's normal (i.e., non-virtual) statistics collection command(s). Data statistics can then be used to estimate the index statistics for the virtual indexes.
  • a B-tree index may be used for XML indexing.
  • the optimizer requires two statistics for an XML index: its cardinality and its size on disk.
  • the cardinality, or total number of entries of an index is a total number of XML nodes in the XML data that match a particular index pattern.
  • Data statistics can be used to estimate a number of nodes that match the particular index pattern. For example, if the frequencies of two paths /a/b and /a/c are n 1 and n 2 , the cardinality of an index whose pattern is /a/* can be estimated by adding n 1 and n 2 .
  • Data statistics such as the size of an index key and the number of keys, can also be used to estimate the size of an index. Multiplying the size of an index key by the number of keys gives an estimate of a total size of an index. With the cardinality and index size statistics of a virtual index in place, the virtual index can be used for cost estimation like any real index.
  • Workloads may contain update, delete, and insert (UDI) statements in addition to queries. Any index recommended must be maintained for each of the UDI statements in the workload. At the same time, update and delete statements may benefit from an index that helps them identify nodes that need to be updated or deleted.
  • UDI update, delete, and insert
  • the benefit of having an index for UDI statements is estimated just like the benefit of indexes for queries.
  • maintenance costs of indexes under UDI statements will also need to be estimated.
  • data statistics can be used to estimate how many XML nodes the statement will affect. An assumption can be made that all the index nodes corresponding to these XML nodes will need to be updated. The estimated number will be used along with information about how the index is implemented to estimate the maintenance cost for this index. This maintenance cost is subtracted from the index benefit.
  • index interaction To evaluate the benefit of a configuration consisting of multiple indexes, the benefit of the individual indexes can be estimated independently and then added up. This approach, however, ignores the interaction between indexes. In particular the benefit of an index will change depending on what other indexes are available because an optimizer can use multiple indexes in its plans. A simplistic approach to take index interaction into account is to evaluate an entire workload with all of the indexes in the configuration created as virtual indexes.
  • indexes can interact with one another if one or more of the following rules apply to the indexes:
  • indexes in the configuration can be divided into smaller sub-configurations, where each sub-configuration includes indexes that may interact with each other according to the index interaction rules set forth above. Initially, a sub-configuration is created for each index in the configuration. The index interaction rules can be used to iteratively merge the sub-configurations that have indexes interacting with each other.
  • an expanded set of candidate indexes will need to be searched to find an optimal index configuration (e.g., maximum benefit) for a given workload, XML data, and system constraints.
  • This combinatorial search problem can be modeled as a 0/1 knapsack problem, which is NP-complete.
  • the size of the knapsack is, for example, a total disk space budget specified by a user.
  • Each candidate index which is an “item” that can be placed in the knapsack, has a cost (e.g., estimated size), and also has a benefit (e.g., reduction in estimated workload execution time due to the presence of this index).
  • indexes interact with one another as the benefit of an index for a query can change depending on whether or not other indexes exist.
  • One approach to solving the 0/1 knapsack problem is to use a greedy search that ignores index interaction. To take index interaction into account, some heuristics can be added to the greedy search to ensure that only indexes with maximum benefit that can be used independently are selected.
  • a top down search that chooses as many general indexes as can fit into the disk budget can also be used to solve the 0/1 knapsack problem.
  • the goals of the greedy search with heuristics and the top down search are fundamentally different.
  • the greedy search with heuristics attempts to find the best possible set of indexes for a given workload, without any consideration for the generality of these indexes, while the top down search attempts to find configurations that are as general as possible so that they can benefit not only the given workload but also any similar future workloads.
  • the two approaches are described in further detail below.
  • the size of each candidate index and a total benefit of each candidate index for a given workload are estimated.
  • the candidate indexes are then sorted according to their benefit/size ratio.
  • candidates are added to the output configuration in sorted order of benefit/size ratio, starting with the highest ratio, and continue until an available disk space budget is exhausted.
  • the approach can be improved by skipping candidates that do not fit into the available disk space budget and continuing to add other candidates that can fit into the budget, trying to accommodate as many indexes as possible.
  • One potential drawback of the greedy search is that multiple indexes that have been selected can be used to answer the same predicate. Unfortunately, an optimizer can use only one of the indexes in its plan.
  • One possible solution to this problem is to compile all queries of a workload after the indexes in the configuration have been selected, and then eliminate indexes that are never used. A problem with this solution is that the extra disk space that is freed will never be used to add more indexes, even though the space could be very useful.
  • indexes x 1 , x 2 , . . . , x n are generalized to index x general , then an expanded set of candidate indexes searched will include all the x i 's and the x general . Because of the high benefit of x general, it is possible that x general will be selected by the greedy search before other x i 's. The problem occurs when there is enough space to accommodate all the x i indexes. If unused indexes are eliminated after index recommendation, either the x i indexes or the x general index will be eliminated, which will free space that will never be used.
  • One solution to this problem is to add one more objective to the candidates search problem: maximizing a number of workload path expressions that use indexes in the selected configuration, or minimizing overlap between the selected indexes. Maximizing the workload benefit remains the primary objective of the search, and heuristics are added to attempt to enforce the new objective in a best effort manner.
  • This new search algorithm adopts the same procedure of the greedy solution described above, but before adding any general index to a configuration, heuristic rules are applied to make sure that the index will not be a replication of others already chosen.
  • x general When a general index, x general , is added to the recommended index configuration, it must be “better” than the indexes it generalizes, x 1 , x 2 , . . . , x n . This is represented in the following two heuristic conditions, which must be satisfied before the general index is added:
  • general indexes are larger than specific indexes because they contain more nodes from the data.
  • the second heuristic restricts the expansion in size that is allowed when a general index is chosen.
  • the first heuristic ensures that the general index is at least as good as the specific indexes. Hence, the approach is biased towards choosing the smallest configuration that is best for the current workload.
  • the greedy search with heuristics recommends the best configuration that fits the specific given workload. Because of that, it can be viewed as over-training for the given workload. If the workload changes even slightly, the recommended configuration may not be of any use. This is acceptable if a database administrator (DBA) knows that the workload will not change at all. For example, if the workload is all the queries in a particular application.
  • DBA database administrator
  • the DBA has assembled a representative training workload, but that the actual workload may be a variation on this training workload.
  • This is often true for relational data, but it is of added importance for XML, because the rich structure of XML allows users to pose queries that retrieve different paths of the data with slight variations. If this is the case, and the workload presented to the design advisor is a representative of a larger class of possible workloads, then the goal of the design advisor should be to choose a set of indexes that is as general as possible, while still benefiting the workload queries.
  • a top down search algorithm can be used to achieve this goal.
  • a Directed Acyclic Graph of candidate indexes is constructed.
  • Each node in the DAG represents an XML pattern and will have as its parents its possible generalization patterns, based on candidate generalization. For example, when generalizing the two candidates /Security/Symbol and /Security/SecInfo/*/Sector to get /Security//*, a node will be created in the DAG for /Security//*, and this node will be a parent of the two candidates.
  • DAG rooted at the most general indexes that can be obtained from the workload.
  • the roots of the DAG are a starting configuration. Since general indexes are typically large in size, the starting configuration is likely to exceed the available disk space budget. Thus, a general index from the configuration is iteratively replaced with its specific (and smaller) child indexes until the configuration fits within a disk budget.
  • ⁇ B and ⁇ C Two new metrics ⁇ B and ⁇ C are introduced. Assume that candidates x 1 , x 2 , . . . , x n are generalized to a candidate x general . There will be nodes in the DAG for each of these candidates, and x general will be a parent of x 1 , x 2 , . . . , x n . Metrics ⁇ B and ⁇ C are defined as follows:
  • the general index with the smallest ⁇ B/ ⁇ C ratio are iteratively selected and replaced with its (more specific) children in the DAG.
  • Pseudo-code for an algorithm that accomplishes this in accordance with an implementation of the invention is set forth below.
  • the algorithm is named topDownSearch and accepts as input a variable basicCandidates.
  • a greedy search may be used instead. In this case, heuristics need not be applied because none of the indexes being searched is general.
  • the invention can take the form of an entirely hardware implementation, an entirely software implementation, or an implementation containing both hardware and software elements.
  • the invention is implemented in software, which includes, but is not limited to, application software, firmware, resident software, microcode, etc.
  • the invention can take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or any instruction execution system.
  • a computer-usable or computer-readable medium can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
  • the medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium.
  • Examples of a computer-readable medium include a semiconductor or solid state memory, magnetic tape, a removable computer diskette, a random access memory (RAM), a read-only memory (ROM), a rigid magnetic disk, and an optical disk.
  • Current examples of optical disks include DVD, compact disk—read-only memory (CD-ROM), and compact disk—read/write (CD-RAN).
  • FIG. 9 depicts a data processing system 900 suitable for storing and/or executing program code.
  • Data processing system 900 includes a processor 902 coupled to memory elements 904 a - b through a system bus 906 .
  • data processing system 900 may include more than one processor and each processor may be coupled directly or indirectly to one or more memory elements through a system bus.
  • Memory elements 904 a - b can include local memory employed during actual execution of the program code, bulk storage, and cache memories that provide temporary storage of at least some program code in order to reduce the number of times the code must be retrieved from bulk storage during execution.
  • I/O devices 908 a - b are coupled to data processing system 900 .
  • I/O devices 908 a - b may be coupled to data processing system 900 directly or indirectly through intervening I/O controllers (not shown).
  • a network adapter 910 is coupled to data processing system 900 to enable data processing system 900 to become coupled to other data processing systems or remote printers or storage devices through communication link 912 .
  • Communication link 912 can be a private or public network. Modems, cable modems, and Ethernet cards are just a few of the currently available types of network adapters.

Abstract

A method, computer-implemented system, and computer program product for creating indexes over XML data managed by a database system are provided. The method, computer-implemented system, and computer program product provide for receiving a workload for the XML data, the workload including one or more database statements, utilizing an optimizer of the database system to enumerate a set of one or more path expressions by creating a virtual universal index based on the workload received and matching a path expression to the virtual universal index, and recommending one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data.

Description

    CROSS-REFERENCE TO RELATED APPLICATIONS
  • Under 35 U.S.C. §120 the present application is a continuation of U.S. patent application Ser. No. 11/849,196, filed Aug. 31, 2007, entitled “INDEX SELECTION FOR XML DATABASE SYSTEMS,” which is incorporated herein by reference.
  • FIELD OF THE INVENTION
  • The present invention relates generally to selection of indexes for XML database systems.
  • BACKGROUND OF THE INVENTION
  • XML database systems are expected to handle increasingly complex queries over increasingly large and highly structured XML databases. Having the correct indexes can significantly improve performance of such queries. Although some XML database systems will employ indexes to improve query performance, deciding which indexes to create may be problematic.
  • SUMMARY OF THE INVENTION
  • A method, computer-implemented system, and computer program product for creating indexes over XML data managed by a database system are provided. The method, computer-implemented system, and computer program product provide for receiving a workload for the XML data, the workload including one or more database statements, utilizing an optimizer of the database system to enumerate a set of one or more path expressions by creating a virtual universal index based on the workload received and matching a path expression to the virtual universal index, and recommending one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data.
  • BRIEF DESCRIPTION OF THE DRAWINGS
  • The accompanying figures illustrate several embodiments of the invention and, together with the description, serve to explain the principles of the invention. One of ordinary skill in the art readily recognizes that the particular embodiments illustrated in the accompanying figures are merely exemplary, and are not intended to limit the scope of the present invention.
  • FIG. 1 depicts a process for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 2 illustrates a system for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 3 shows a process for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 4 depicts architecture of a system for selecting indexes to be created over XML data according to an implementation of the invention.
  • FIG. 5 illustrates a table listing enumerated candidate index patterns for sample queries according to an implementation of the invention.
  • FIG. 6 shows an example of an expression tree representing a path expression.
  • FIG. 7 depicts a table with a set of rules used by an algorithm according to an implementation of the invention.
  • FIG. 8 illustrates a table listing generalized candidate index patterns for sample queries according to an implementation of the invention.
  • FIG. 9 shows a block diagram of a data processing system with which implementations of the invention can be implemented.
  • DETAILED DESCRIPTION
  • The present invention generally relates to selection of indexes for XML database systems. The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. Various modifications to the described embodiments and the generic principles and features described herein will be readily apparent to those skilled in the art. Thus, the present invention is not intended to be limited to the embodiments shown but is to be accorded the widest scope consistent with the principles and features described herein.
  • Selection of indexes is an important part of any database system design as indexes can significantly impact workload performance by enabling quicker and more efficient access to data. Determining which indexes are suitable for XML database systems is now increasingly important because XML is becoming the standard language in which data are represented and exchanged.
  • XML, which stands for eXtensible Markup Language, is a software language that can be used to label information from diverse data sources. XML database systems may be systems that only support XML data or may be systems that support XML and other types of data (e.g., relational data). Index selection for other types of data, such as relational data, differs from index selection for XML data because with XML data, a variety of index types (e.g., structural, value, and so forth) may be needed. Additionally, the structure of XML data may be more complex. XML indexes also differ from regular indexes in that not only do they define the data type and column to index but also an XML pattern within the XML column to index for values indexes.
  • Further, some database systems may permit partial indexing of data. For instance, an XML database system may allow an index to be created for a portion of an XML document that matches an index pattern. The index pattern may be expressed as a path expression (e.g., ‘//people/person/homepage’) such that only the XML elements reachable by the path expression are included in the index.
  • Partial indexing leads to smaller indexes that only include portion(s) of document(s) that are useful. Index maintenance is also more efficient with partial indexing. Additionally, index lookup performance is improved over indexes on whole document(s). Selection of indexes, however, is further complicated because not only do decisions need to be made as to which type of indexes to create and which documents to index, decisions will also have to be made as to which portions of each document to index.
  • Solutions have been proposed to tackle the problems associated with selecting indexes for XML data. The proposed solutions, however, are completely independent of database system optimizers. As a result, there is no guarantee that any index selected will be used by an optimizer. In addition, there is no guarantee that the benefits of a selected index are accurately estimated. Some proposed solutions also do not attempt to select indexes that are useful for multiple queries, fail to take into account increased costs associated with updates, deletes, and inserts, and ignore system constraints (e.g., disk storage limits).
  • Depicted in FIG. 1 is a process 100 for selecting indexes to be created over XML data according to an implementation of the invention. At 102, a workload for the XML data is received. The workload includes one or more database statements. Database statements may be expressed using XQuery, which is a query language that can be used to query XML data. At 104, an optimizer is utilized to recommend a set of one or more path expressions to be used to create one or more indexes over the XML data based on the workload received. Path expressions may be expressed using XPath, which is a language that can be used to address parts of an XML document.
  • Process 100 may include additional process blocks (not shown) of creating one or more indexes over the XML data using the set of one or more path expressions recommended and storing the one or more indexes over the XML data in memory or on disk. An index may be viewed as providing an efficient mapping from one or more path expressions to XML elements that are reachable by the one or more path expressions. In one implementation, at least one of the one or more indexes to be created over the XML data is a partial index.
  • Indexes that are created may be structural indexes or value indexes. Structural indexes help in speeding up navigation through hierarchical structure of XML data and answering queries, such as, “/Security/Symbol”, which is requesting all security symbols. Value indexes help in retrieving XML elements based on some condition of the value they contain and answering queries, such as, “/Security[Yield>=4.5]”, which is requesting all securities with a yield greater than or equal to 4.5.
  • In one implementation, recommendation of the set of one or more path expressions is also based on one or more system constraints (e.g., disk space, schema, and so forth). Recommendation of the set of one or more path expressions may also take into account increased costs associated with update, delete, and insert (UDI) statements when one or more indexes are created using the set of one or more path expressions recommended.
  • FIG. 2 illustrates a system 200 for selecting indexes to be created over XML data according to an implementation of the invention. System 200 includes a database 202 that stores the XML data. In addition, system 200 includes an optimizer 204 in communication with database 202. Optimizer 204 optimizes database statements seeking access to the XML data stored in database 202. An index advisor 206 that is in communication with optimizer 204 is also included in system 200.
  • Although database 202, optimizer 204, and index advisor 206 are all part of system 200, each one may be remotely located from one another (e.g., on different computers, at different locations, or the like). In FIG. 2, a workload 208 is received by index advisor 206. Workload 208 includes one or more database statements. Index advisor 206 then uses optimizer 204 to recommend a set of one or more path expressions 210 based on the workload 208 received by index advisor 206. The set of one or more path expressions 210 can be used to create one or more indexes (not shown) over the XML data stored in database 202.
  • Shown in FIG. 3 is a process 300 for selecting indexes to be created over XML data managed by a database system according to an implementation of the invention. At 302, a workload for the XML data, which includes one or more database statements, is received. At 304, an optimizer of the database system is utilized to enumerate a plurality of candidate path expressions based on the workload received. At 306, the plurality of candidate path expressions enumerated is generalized to generate additional candidate path expressions.
  • At 308, the optimizer is utilized to estimate a benefit associated with each candidate path expression in relation to the workload received. For each candidate path expression, the optimizer is also utilized to estimate a size of an index to be created using the respective candidate path expression at 310. At 312, one or more candidate path expressions are recommended for use in creating one or more indexes over the XML data.
  • Recommendation of the one or more candidate path expressions is based on at least one of a system constraint, the estimated size of the index to be created using each candidate path expression, and the estimated benefit associated with each candidate path expression. In addition, the recommendation may be based on interaction between the one or more candidate path expressions.
  • FIG. 4 depicts architecture of a system 400 for selecting indexes to be created over XML data according to an implementation of the invention. System 400 includes an index advisor 402 that is in communication with an optimizer 404. Optimizer 404 has two modes, an enumerate indexes mode and an evaluate indexes mode. In the enumerate indexes mode, optimizer 404 takes a query and generates index patterns (e.g., path expressions) that can be useful to the query. The index patterns can then be used to create indexes. In the evaluate indexes mode, optimizer 404 simulates an index configuration based on one or more index patterns and estimates the cost of a query under the index configuration. This mode also estimates the statistics for simulated indexes to allow the costing to be more accurate.
  • A high-level framework of an index recommendation process is as follows: First, index advisor 402 receives a query workload. For every query in the workload, optimizer 404 is relied upon to enumerate a set of candidate index patterns useful for the particular query, which can be used to create indexes. Next, index advisor 402 expands the set of candidate index patterns generated by optimizer 404 to include more general index patterns, each of which can potentially benefit multiple queries, either from the workload or from other workloads.
  • Finally, the space of possible index configurations is searched to find the optimal configuration, which maximizes the performance benefit to the workload while satisfying system constraints (e.g., disk space). The index recommendation process is described in more detail below in conjunction with the following sample queries:
  • Q1:
    for $sec in
    SECURITY(‘SDOC’)/Security
    where $s/Symbol=“BCIIPRC”
    return $s
    Q2:
    for $sec in SECURITY(‘SDOC’)/Security
    where
    $sec/SecInfo/*/Sector=“Energy” and
    $sec/Yield>4.5
    return
    <Security> {$sec/Name} </Security>
  • Enumerating Candidates
  • According to an implementation of the invention, when an optimizer is used for index pattern enumeration, the optimizer creates and uses virtual indexes during the enumeration process. Virtual indexes are hypothetical indexes that are added to a database catalog and to all internal data structures of the optimizer, but are not physically created in memory or on disk and no data is inserted into them. Virtual indexes cannot be used for query execution.
  • The optimizer uses virtual indexes in conjunction with its index matching capabilities to assist an index advisor to enumerate candidate index patterns, which in turn, can be used to create candidate indexes. During an index matching process, the optimizer decides, for a current query being optimized, which of the available indexes can be used by the current query, and how can they be used (e.g., for which predicates in the query). Predicates matched to indexes can then be used as candidate index patterns.
  • By coupling the process of enumerating candidate index patterns in the index advisor with the process of index matching in the optimizer, indexes to be created based on the candidate index patterns enumerated by the index advisor are assured to be ones that can actually be matched and used by the optimizer. In addition, the functionality of index matching in the optimizer is leveraged so that there will be no need to replicate this functionality outside of the optimizer.
  • To leverage the index matching capabilities of the optimizer, one or more virtual universal or general indexes may be created over XML data (e.g., //* for a given XML column and data type, //@ for a given attribute, and so forth). These virtual general indexes virtually index all elements the XML data and hence can be matched with any path expression that can be answered using the index. The optimizer can then optimize a query with these virtual general indexes in place. After index matching, all path expressions in the query that are matched with a virtual general index are collected.
  • Every path expression, p, that matches a virtual general index will also match an index that is specific to it (e.g., an index created using path expression p). Essentially, the optimizer has answered the question: “If all possible indexes were available, which ones would be considered for this query?” As such, all path expressions matched with a virtual general index for a particular query will be the candidate path expressions for the particular query.
  • In one implementation, each candidate path expression and corresponding information (e.g., data type, full path expression, namespace declarations, and so forth) are recorded (e.g., in memory, on disk, or somewhere else). Illustrated in FIG. 5 is a table 500 that lists enumerated candidate index patterns for the two sample queries Q1 and Q2.
  • The candidate enumeration process allows the index matching capabilities of the optimizer to be leveraged, as well as, its query parsing, type checking, and query rewriting capabilities. Hence, the index advisor can support any query language supported by the optimizer (e.g., XQuery, SQL/XML, and so forth). The index advisor can also support any type checks or type casts that the optimizer performs when using an index, and it can enumerate any indexes that are only exposed by query rewrites in the optimizer.
  • A different virtual universal index may be created for each element, attribute, and/or data type in the XML data. Rather than creating a virtual universal index for each element, attribute, and/or data type in the XML data, a virtual universal index may be created for each element, attribute, and/or data type involved in a particular query being optimized.
  • To enumerate candidate index patterns, the index advisor sends each query in a workload to the optimizer for optimization. Index patterns chosen by the optimizer for each query are then added to a set of candidate index patterns that will be considered while searching for an optimal index configuration for the XML data.
  • Generalizing Candidates
  • Candidate index patterns enumerated above are specific to individual queries as an optimizer identifies patterns specific to each query that could benefit from an index. The optimizer, however, may not be able to identify common patterns across queries. Common patterns can lead to more general indexes that can benefit multiple queries in a current workload and in future workloads.
  • To address this, candidate index patterns enumerated by the optimizer are expanded by applying a set of generalization rules that create more general candidate index patterns useful to multiple queries from the candidate index patterns that are specific to individual queries. For example, as shown in table 500 of FIG. 5, path expressions “/Security/Symbol” and “/Security/SecInfo/Sector” are identified by the optimizer as candidates for indexing. Based on these two path expressions, an additional and more general candidate path expression “/Security//*” can be generated.
  • The additional candidate path expression covers the original two candidate path expressions as well as other path expressions that could potentially exist in the XML data, such as “/Security//Industry”. The index advisor can recommend the additional candidate path expression as an alternative to or in addition to the two original candidate path expressions. Although the new candidate may have a size that is greater than the total size of the two original candidates as it covers more paths, it can potentially be useful for queries beyond those that are covered by the other two.
  • Generalization of candidate path expressions can be done in pairs or one candidate at a time. To generalize a candidate path expression, the path expression may be represented as an expression tree, such as an XPS tree (XPath Step tree). An XPS tree is composed of labeled nodes. Each node is labeled with its navigation axis and its node test, where the navigation axis is the special axis root or one of: child, descendant, or attribute. The test can be either a name test or a wildcard test.
  • Each node can have two children, the left child represents any predicate on the node, while the right child represents a next step in the expression. FIG. 6 shows an example of an expression tree 600 representing a path expression. Expression tree 600 in an XPS tree. In the example, the node ‘Security’ has both an equality predicate child and a next step child. Path expressions may contain both navigational and predicate branching. Navigation can contain label wildcards, “*”, child axis navigation, “/”, and descendant navigation, “//”. Predicates can involve comparison operators <, ≦, >, ≧, =, #, It, le, ge, gt, eq, ne, and so forth. Tree representation can be obtained by parsing path expressions. After generalization, a generalized tree can be traversed to obtain a corresponding path expression.
  • Generalizing Pairs of Candidates
  • Generalized candidate path expressions can be found by iteratively applying several generalization rules to each pair of candidate path expressions enumerated for specific queries and to resulting generalized candidate path expressions. This process may continue until no new generalized path expressions can be generated. The rules consider two path expressions concurrently and try to find common path nodes between the two paths and capture the commonality in a new generalized path expression(s). The new generalized path expression(s) are then added to candidate path expressions already enumerated.
  • Set forth below is pseudo-code for an algorithm that can be used to find more generalized candidates from pairs of existing candidates according to an implementation of the invention. The algorithm is called ‘generalizeXPworkload’, which accepts as input XPset.
  • start ← 0
    end ← XPset.size
    while no more new paths are generalized do
    for i = start to end − 1 do
    for j = i + 1 to end do
    if pi and pj have same data type and defined on same table
    then
    genXPath ← generalizeStep(null, pi, pj)
    end if
    if genXPath ∉ XPset then
    add new path to XPset
    end if
    end for
    end for
    start ← end + 1
    end ← end + number of new generated paths
    end while
  • In the ‘generalizeXPworkload’ algorithm, data type, table name, and column name of the pairs are checked for compatibility. Data type, however, may not be checked for path expressions to be used to create structural indexes. After checking data type, table name, and column name, another algorithm called ‘generalizedStep’ is called for every qualifying pair. The ‘generalizedStep’ algorithm applies generalization rules to a pair of path expressions to find all common sub-expressions. Variable pi is used to refer to the root of a subtree in a path expression currently being generalized and variable genXPath is used to refer to an expression tree of a generalized path expression being generated.
  • During generalization of a pair of path expressions, paths are divided into two parts: a last step that represents nodes being indexed and a path leading to the last step. In the generalization, whenever a predicate occurs in the middle of a path expression, it is generalized to include all nodes, not just the ones qualified by the predicate. For example, generalization of the path expression ‘/Security[Symbol=“BCIIP RC”]//Sector’ with any other path expression will be handled the same as ‘/Security//Sector’, since all nodes of ‘/Security//Sector’ are included when generalizing, not just the qualified ones.
  • Below is pseudo-code for the ‘generalizedStep’ algorithm according to an implementation of the invention. The ‘generalizedStep’ algorithm accepts as input genXPath, p1, p2.
  • if p1.nameTest = p2.nameTest then
    create newNode with p1.nameTest and gAxis(p1.axis, p2.axis)
    append newNode to genXPath
    return {generalizeComp(genXPath, p1, p2)}
    else
    create newNode with wildcard test and gAxis (p1.axis, p2.axis)
    append newNode to genXPath
    return {generalizeComp(genXPath, p1, p2)}
    end if
  • As seen above, generalization of path expressions is divided into the ‘generalizedStep’ algorithm and a ‘generalizedComp’ algorithm. Each algorithm returns lists of genXPaths. The ‘generalizedStep’ algorithm takes two expression trees, generalizes the roots of these trees, and appends the new generalized node to the genXPath expression.
  • For root nodes f1 and f2 of trees p1 and p2, root nodes f1 and f2 are checked to see whether they have the same axis and name test information. If so, the newly generated node retains the same axis and name test information as f1 and f2. If not, a generalized form for the axis and found and the name test is replaced with a wildcard label. The new node is then appended to the genXPath tree currently being generated and passed along with p1 and p2 to the ‘generalizedComp’ algorithm to process the rest of the expressions. The list of generated trees returned from the ‘generalizedComp’ algorithm is passed back to the ‘generalizeXPworkload’ algorithm to be appended to list of candidates.
  • The ‘generalizeComp’ algorithm plays the role of traversing the trees by advancing the tree pointers of p1 and p2 according to a set of rules. Depicted in FIG. 7 is a table 700 with a set of rules used by the ‘generalizedComp’ algorithm according to an implementation of the invention. The set of rules are designed to generate candidates that are as general as possible. In some cases, several choices may be considered in parallel, and hence more than one genXPath may be found and a list of all of these genXPaths is returned.
  • In one implementation, to generalize a pair of XPS trees, begin at root nodes of both trees and proceed by advancing their pointers. At each step, attempt is made to generalize the nodes currently being processed. For example, to generalize candidates C1: /Security/Symbol and C2: /Security/SecInfo/*/Sector from table 500 in FIG. 5, an initial call is made to generalizedStep(null, /Security/Symbol, /Security/SecInfo/*/Sector). The ‘generalizedStep’ algorithm looks at the nodes /Security in both paths and recognizes that they have the same name tests, therefore it creates a node with a /Security name test and appends it to a genXPath being produced. It then calls generalizedComp(/Security, /Security/Symbol, /Security/SecInfo/*/Sector) to complete processing these expressions.
  • In this call, Rule 4 in table 700 in FIG. 7 applies, and the pointer of the second expression is advanced until /Sector is reached. Then generalizedStep (/Security/*, /Symbol, //Sector) is called. As nodes /Symbol and /Sector have different name tests, a new node with a wildcard name test is appended to the genXPath. This time when generalizedComp(/Security/*/*, /Symbol, /Sector) is called, Rule 1 in table 700 is applied and the expression /Security//* is returned after processing the consecutive wildcard nodes. Finally, the list of candidates in table 500 can be extended to include candidate C4 in a table 800 illustrated in FIG. 8.
  • If nodes reoccur multiple times in the path expressions being processed, multiple generalized trees can be generated. For example, running the generalization algorithm on two expressions /a/b/c/@d and /c/a/b/@d, Rule 5 in table 700 will be applied and more than one common sub-expression may be found for the two expressions. Hence, two new expressions will be returned to be added to the candidate set: //a/b//@d and //c//@d.
  • For every genXPath, the candidate index patterns that were combined to produce it are tracked. The generalization step can also be used to check if a candidate path expression is a generalization of another. If the generalization of a pair of path expressions p1 and p2 is equal to one of them, say p1, then p1 is a generalization of p2, then the fact that queries that benefit from p2 will also benefit from p1 can be recorded.
  • Generalizing Individual Candidates
  • Some path expressions might not be generalized with any other path expression. An example of this is candidate C3 in table 500 of FIG. 5. To get more general candidates even from individual candidate path expressions with no common sub-expressions, a technique that predicts the existence of other expressions similar to a candidate can be used. In one implementation, the technique replaces a last non-* navigation step in a candidate path expression with a * navigation step. For example, the path C3 in table 500 can be generalized into /Security/*. A more comprehensive approach may consult the data to determine the usefulness of such a generalization and recommend other generalizations.
  • Estimating Benefits
  • An optimizer can be used by an index advisor to estimate the benefit to a workload of having a particular index configuration. Virtual indexes can be created using candidate path expressions and used to estimate the cost of a workload with the virtual indexes in place. These virtual indexes can be included with other existing real indexes when performing index matching to find candidate indexes and when determining an execution plan for a query. After optimizing a query using virtual indexes, the optimizer returns a set of indexes used along with statistics and cost information. The information is used by the index advisor to determine the benefit of using an index or a configuration consisting of multiple indexes.
  • Statistics Generation
  • While finding an execution plan in the presence of one or more virtual indexes, the optimizer will need statistics about these virtual indexes to get better cost estimates. Some of these statistics are data statistics, such as the distinct path expressions being indexed and their frequencies, while others are index statistics, such as a number of disk pages occupied by the index. All the necessary data statistics may be collected using an optimizer's normal (i.e., non-virtual) statistics collection command(s). Data statistics can then be used to estimate the index statistics for the virtual indexes.
  • A B-tree index may be used for XML indexing. When a B-tree index is used, the optimizer requires two statistics for an XML index: its cardinality and its size on disk. The cardinality, or total number of entries of an index, is a total number of XML nodes in the XML data that match a particular index pattern. Data statistics can be used to estimate a number of nodes that match the particular index pattern. For example, if the frequencies of two paths /a/b and /a/c are n1 and n2, the cardinality of an index whose pattern is /a/* can be estimated by adding n1 and n2.
  • Data statistics, such as the size of an index key and the number of keys, can also be used to estimate the size of an index. Multiplying the size of an index key by the number of keys gives an estimate of a total size of an index. With the cardinality and index size statistics of a virtual index in place, the virtual index can be used for cost estimation like any real index.
  • Update, Delete, and Insert Costing
  • To evaluate the benefit of an index for a given workload, the cost of queries in the workload when the index is available is subtracted from the cost of the queries when the index is not present. The difference represents a reduction in cost or benefit of using this index for this workload. Workloads may contain update, delete, and insert (UDI) statements in addition to queries. Any index recommended must be maintained for each of the UDI statements in the workload. At the same time, update and delete statements may benefit from an index that helps them identify nodes that need to be updated or deleted.
  • The benefit of having an index for UDI statements is estimated just like the benefit of indexes for queries. However, maintenance costs of indexes under UDI statements will also need to be estimated. To estimate the maintenance cost of UDI statements, data statistics can be used to estimate how many XML nodes the statement will affect. An assumption can be made that all the index nodes corresponding to these XML nodes will need to be updated. The estimated number will be used along with information about how the index is implemented to estimate the maintenance cost for this index. This maintenance cost is subtracted from the index benefit.
  • Index Interaction
  • To evaluate the benefit of a configuration consisting of multiple indexes, the benefit of the individual indexes can be estimated independently and then added up. This approach, however, ignores the interaction between indexes. In particular the benefit of an index will change depending on what other indexes are available because an optimizer can use multiple indexes in its plans. A simplistic approach to take index interaction into account is to evaluate an entire workload with all of the indexes in the configuration created as virtual indexes.
  • Two indexes can interact with one another if one or more of the following rules apply to the indexes:
      • Indexes x1 and x2 can be used in the same query. Keeping track of which queries can benefit from which indexes will enable this type of interaction to be detected
      • Index x1 can be used in the queries that recommended index x2. Keeping track of this case will be useful when indexes are generalized
      • Index x1 was generated by generalizing index x2. As a result, the optimizer can choose only one of them for any query that can benefit from these indexed nodes. This information may also available after the index generalization
  • To estimate the benefit of a configuration of indexes, indexes in the configuration can be divided into smaller sub-configurations, where each sub-configuration includes indexes that may interact with each other according to the index interaction rules set forth above. Initially, a sub-configuration is created for each index in the configuration. The index interaction rules can be used to iteratively merge the sub-configurations that have indexes interacting with each other.
  • Keeping track of the queries that can use the indexes in each sub-configuration will reduce the number of optimizer calls that will be needed when the index configuration changes. When the configuration changes, only queries that can benefit from those sub-configurations that have changed will be evaluated, which allow index interaction to be taken into account without exhaustively re-evaluating the workload at each step of the search.
  • After candidate enumeration and generalization, an expanded set of candidate indexes will need to be searched to find an optimal index configuration (e.g., maximum benefit) for a given workload, XML data, and system constraints. This combinatorial search problem can be modeled as a 0/1 knapsack problem, which is NP-complete. The size of the knapsack is, for example, a total disk space budget specified by a user. Each candidate index, which is an “item” that can be placed in the knapsack, has a cost (e.g., estimated size), and also has a benefit (e.g., reduction in estimated workload execution time due to the presence of this index).
  • The problem is further complicated by the fact that indexes interact with one another as the benefit of an index for a query can change depending on whether or not other indexes exist. One approach to solving the 0/1 knapsack problem is to use a greedy search that ignores index interaction. To take index interaction into account, some heuristics can be added to the greedy search to ensure that only indexes with maximum benefit that can be used independently are selected.
  • A top down search that chooses as many general indexes as can fit into the disk budget can also be used to solve the 0/1 knapsack problem. The goals of the greedy search with heuristics and the top down search are fundamentally different. The greedy search with heuristics attempts to find the best possible set of indexes for a given workload, without any consideration for the generality of these indexes, while the top down search attempts to find configurations that are as general as possible so that they can benefit not only the given workload but also any similar future workloads. The two approaches are described in further detail below.
  • Greedy Search with Heuristics
  • With the greedy approximation of the NP-complete 0/1 knapsack problem, the size of each candidate index and a total benefit of each candidate index for a given workload are estimated. The candidate indexes are then sorted according to their benefit/size ratio. Finally, candidates are added to the output configuration in sorted order of benefit/size ratio, starting with the highest ratio, and continue until an available disk space budget is exhausted. As this is an approximate solution, the approach can be improved by skipping candidates that do not fit into the available disk space budget and continuing to add other candidates that can fit into the budget, trying to accommodate as many indexes as possible.
  • One potential drawback of the greedy search is that multiple indexes that have been selected can be used to answer the same predicate. Unfortunately, an optimizer can use only one of the indexes in its plan. One possible solution to this problem is to compile all queries of a workload after the indexes in the configuration have been selected, and then eliminate indexes that are never used. A problem with this solution is that the extra disk space that is freed will never be used to add more indexes, even though the space could be very useful.
  • For example, if indexes x1, x2, . . . , xn are generalized to index xgeneral, then an expanded set of candidate indexes searched will include all the xi's and the xgeneral. Because of the high benefit of xgeneral, it is possible that xgeneral will be selected by the greedy search before other xi's. The problem occurs when there is enough space to accommodate all the xi indexes. If unused indexes are eliminated after index recommendation, either the xi indexes or the xgeneral index will be eliminated, which will free space that will never be used.
  • One solution to this problem is to add one more objective to the candidates search problem: maximizing a number of workload path expressions that use indexes in the selected configuration, or minimizing overlap between the selected indexes. Maximizing the workload benefit remains the primary objective of the search, and heuristics are added to attempt to enforce the new objective in a best effort manner.
  • This new search algorithm adopts the same procedure of the greedy solution described above, but before adding any general index to a configuration, heuristic rules are applied to make sure that the index will not be a replication of others already chosen. When a general index, xgeneral, is added to the recommended index configuration, it must be “better” than the indexes it generalizes, x1, x2, . . . , xn. This is represented in the following two heuristic conditions, which must be satisfied before the general index is added:
  • Benefit ( x general ) Benefit ( x 1 , x 2 , , x n ) Size ( x general ) ( 1 + β ) i = 1 n Size ( x i )
  • Most of the time, general indexes are larger than specific indexes because they contain more nodes from the data. The second heuristic restricts the expansion in size that is allowed when a general index is chosen. The first heuristic ensures that the general index is at least as good as the specific indexes. Hence, the approach is biased towards choosing the smallest configuration that is best for the current workload.
  • Top Down Search
  • The greedy search with heuristics recommends the best configuration that fits the specific given workload. Because of that, it can be viewed as over-training for the given workload. If the workload changes even slightly, the recommended configuration may not be of any use. This is acceptable if a database administrator (DBA) knows that the workload will not change at all. For example, if the workload is all the queries in a particular application.
  • However, another likely scenario is that the DBA has assembled a representative training workload, but that the actual workload may be a variation on this training workload. This is often true for relational data, but it is of added importance for XML, because the rich structure of XML allows users to pose queries that retrieve different paths of the data with slight variations. If this is the case, and the workload presented to the design advisor is a representative of a larger class of possible workloads, then the goal of the design advisor should be to choose a set of indexes that is as general as possible, while still benefiting the workload queries. A top down search algorithm can be used to achieve this goal.
  • In one implementation, a Directed Acyclic Graph (DAG) of candidate indexes is constructed. Each node in the DAG represents an XML pattern and will have as its parents its possible generalization patterns, based on candidate generalization. For example, when generalizing the two candidates /Security/Symbol and /Security/SecInfo/*/Sector to get /Security//*, a node will be created in the DAG for /Security//*, and this node will be a parent of the two candidates.
  • At the end of this construction phase, there will be a DAG rooted at the most general indexes that can be obtained from the workload. The roots of the DAG are a starting configuration. Since general indexes are typically large in size, the starting configuration is likely to exceed the available disk space budget. Thus, a general index from the configuration is iteratively replaced with its specific (and smaller) child indexes until the configuration fits within a disk budget.
  • To choose the general index to replace, two new metrics ΔB and ΔC are introduced. Assume that candidates x1, x2, . . . , xn are generalized to a candidate xgeneral. There will be nodes in the DAG for each of these candidates, and xgeneral will be a parent of x1, x2, . . . , xn. Metrics ΔB and ΔC are defined as follows:
  • Δ B = Benefit ( x general ) - 0 i n Benefit ( x i ) Δ C = Size ( x general ) - 0 i n Size ( x i )
  • Since the goal is to obtain the maximum total benefit for the workload with the most general configuration that fits in the disk space budget, the general index with the smallest ΔB/ΔC ratio are iteratively selected and replaced with its (more specific) children in the DAG. Pseudo-code for an algorithm that accomplishes this in accordance with an implementation of the invention is set forth below. The algorithm is named topDownSearch and accepts as input a variable basicCandidates. In one implementation, if all general statistics have been considered and all of the disk budget has not been used up, then a greedy search may be used instead. In this case, heuristics need not be applied because none of the indexes being searched is general.
  • candidates ← basicCandidates
    currSize ← candidates.size
    while currSize > diskConstraint do
    for cand = 1 to candidates.num do
    calculate ΔB/ΔC of cand
    end for
    candidates ← configuration after replacing candidate whose (ΔB/ΔC)
    is minimum with its children
    currSize ← candidates.size
    end while
  • The invention can take the form of an entirely hardware implementation, an entirely software implementation, or an implementation containing both hardware and software elements. In one aspect, the invention is implemented in software, which includes, but is not limited to, application software, firmware, resident software, microcode, etc.
  • Furthermore, the invention can take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or any instruction execution system. For the purposes of this description, a computer-usable or computer-readable medium can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
  • The medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium. Examples of a computer-readable medium include a semiconductor or solid state memory, magnetic tape, a removable computer diskette, a random access memory (RAM), a read-only memory (ROM), a rigid magnetic disk, and an optical disk. Current examples of optical disks include DVD, compact disk—read-only memory (CD-ROM), and compact disk—read/write (CD-RAN).
  • FIG. 9 depicts a data processing system 900 suitable for storing and/or executing program code. Data processing system 900 includes a processor 902 coupled to memory elements 904 a-b through a system bus 906. In other implementations, data processing system 900 may include more than one processor and each processor may be coupled directly or indirectly to one or more memory elements through a system bus.
  • Memory elements 904 a-b can include local memory employed during actual execution of the program code, bulk storage, and cache memories that provide temporary storage of at least some program code in order to reduce the number of times the code must be retrieved from bulk storage during execution. As shown, input/output or I/O devices 908 a-b (including, but not limited to, keyboards, displays, pointing devices, etc.) are coupled to data processing system 900. I/O devices 908 a-b may be coupled to data processing system 900 directly or indirectly through intervening I/O controllers (not shown).
  • In the implementation, a network adapter 910 is coupled to data processing system 900 to enable data processing system 900 to become coupled to other data processing systems or remote printers or storage devices through communication link 912. Communication link 912 can be a private or public network. Modems, cable modems, and Ethernet cards are just a few of the currently available types of network adapters.
  • While various implementations for selecting XML indexes have been described, the technical scope of the present invention is not limited thereto. For example, the present invention is described in terms of particular systems having certain components and particular methods having certain steps in a certain order. One of ordinary skill in the art, however, will readily recognize that the methods described herein can, for instance, include additional steps and/or be in a different order, and that the systems described herein can, for instance, include additional or substitute components. Hence, various modifications or improvements can be added to the above implementations and those modifications or improvements fall within the technical scope of the present invention.

Claims (20)

What is claimed is:
1. A method for creating indexes over XML data managed by a database system, the method comprising:
receiving a workload for the XML data, the workload including one or more database statements;
utilizing an optimizer of the database system to enumerate a set of one or more candidate path expressions by creating a virtual universal index based on the workload received and matching a path expression to the virtual universal index; and
recommending one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data.
2. The method of claim 1, further comprising:
generalizing the set of one or more candidate path expressions to generate additional candidate path expressions;
utilizing the optimizer to estimate a benefit associated with each candidate path expression in relation to the workload received;
utilizing the optimizer to estimate a size of an index to be created using each candidate path expression; and
recommending the one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data based on at least one of a system constraint, the estimated benefit associated with each candidate path expression, and the estimated size of the index to be created using each candidate path expression.
3. The method of claim 2, wherein utilizing the optimizer to enumerate the set of one or more candidate path expressions comprises:
sending each of the one or more database statements of the workload to the optimizer for the optimizer to:
create one or more virtual universal indexes based upon one or more path expressions over the XML data, a virtual universal index being created for each data type, element, and attribute in the database statement being processed,
match one or more path expressions in the database statement being processed to the one or more virtual universal indexes, and
enumerate each of the one or more path expressions matched as the set of one or more candidate path expressions.
4. The method of claim 2, wherein generalizing the set of one or more candidate path expressions comprises:
selecting a first candidate path expression and a second candidate path expression;
determining whether the first candidate path expression and the second candidate path expression have one or more common sub-expressions;
responsive to the first candidate path expression and the second candidate path expression having one or more common sub-expressions, returning each of the one or more common sub-expressions as an additional candidate path expression; and
responsive to the first candidate path expression and the second candidate path expression not having one or more common sub-expressions,
modifying each of the first and second candidate path expressions by replacing a last non-* navigating step in each of the first and second candidate path expressions with a* navigation step, and
returning the modified first and second candidate path expressions as the additional candidate path expressions.
5. The method of claim 2, wherein utilizing the optimizer to estimate the benefit associated with each candidate path expression comprises:
sending each candidate path expression to the optimizer for the optimizer to:
estimate a cardinality and a size of an index created over the XML data using the candidate path expression,
calculate a cost of executing the one or more database statements in the workload when the index is available (first cost),
calculate a cost of executing the one or more database statements in the workload when the index is not available (second cost),
calculate a cost of maintaining the index with respect to an update, a deletion, or an insertion (third cost), and
subtract from the second cost a sum of the first cost and the third cost to obtain the estimated benefit associated with the candidate path expression.
6. The method of claim 1, wherein recommending one or more path expressions from the set of one or more candidate path expressions comprises:
sorting the set of one or more candidate path expressions according to a benefit-to-size ratio from highest to lowest; and
starting from a highest benefit-to-size ratio candidate path expression, adding a candidate path expression to the set of one or more candidate path expressions in sort order,
unless an index to be created using the candidate path expression will not fit into an available disk space budget, and
until one or more indexes to be created using the set of one or more candidate path expressions will exhaust the available disk budget.
7. The method of claim 1, wherein recommending one or more path expressions from the set of one or more candidate path expressions comprises:
constructing a directed acyclic graph (DAG) using the set of one or more candidate path expressions, each node of the DAG corresponding to one candidate path expression;
selecting one or more nodes of the DAG, wherein candidate path expressions corresponding to the one or more nodes selected are included in the one or more path expressions;
iteratively replacing at least one of the one or more nodes selected with one or more child nodes until one or more indexes to be created using the one or more path expressions corresponding to the one or more child nodes will fit within an available disk budget; and
replacing each candidate path expression included in the set of one or more candidate path expressions corresponding to the at least one of the one or more nodes with the one or more path expressions corresponding to the one or more child nodes replacing the at least one of the one or more nodes.
8. A computer-implemented system for creating indexes over XML data managed by a database system, the system comprising:
a database storing the XML data;
an optimizer in communication with the database, the optimizer optimizing database statements seeking access to the XML data stored in the database; and
an index advisor in communication with the optimizer, wherein the index advisor:
receives a workload for the XML data, the workload including one or more database statements;
utilizes an optimizer of the database system to enumerate a set of one or more candidate path expressions by creating a virtual universal index based on the workload received and matching a path expression to the virtual universal index; and
recommends one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data.
9. The computer-implemented system of claim 8, further wherein the index advisor:
generalizes the set of one or more candidate path expressions to generate additional candidate path expressions;
utilizes the optimizer to estimate a benefit associated with each candidate path expression in relation to the workload received;
utilizes the optimizer to estimate a size of an index to be created using each candidate path expression; and
recommends the one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data based on at least one of a system constraint, the estimated benefit associated with each candidate path expression, and the estimated size of the index to be created using each candidate path expression.
10. The computer-implemented system of claim 8, wherein the index advisor utilizes the optimizer of the database system to enumerate the set of one or more candidate path expressions by:
sending each of the one or more database statements of the workload to the optimizer for the optimizer to:
create one or more virtual universal indexes based upon one or more path expressions over the XML data, a virtual universal index being created for each data type, element, and attribute in the database statement being processed,
match one or more path expressions in the database statement being processed to the one or more virtual universal indexes, and
enumerate each of the one or more path expressions matched as the set of one or more candidate path expressions.
11. The computer-implemented system of claim 9, wherein the index advisor generalizes the set of one or more candidate path expressions by:
selecting a first candidate path expression and a second candidate path expression;
determining whether the first candidate path expression and the second candidate path expression have one or more common sub-expressions;
responsive to the first candidate path expression and the second candidate path expression having one or more common sub-expressions, returning each of the one or more common sub-expressions as an additional candidate path expression; and
responsive to the first candidate path expression and the second candidate path expression not having one or more common sub-expressions,
modifying each of the first and second candidate path expressions by replacing a last non-* navigating step in each of the first and second candidate path expressions with a* navigation step, and
returning the modified first and second candidate path expressions as the additional candidate path expressions.
12. The computer-implemented system of claim 9, wherein the index advisor utilizes the optimizer to estimate the benefit associated with each candidate path expression by:
sending each candidate path expression to the optimizer for the optimizer to:
estimate a cardinality and a size of an index created over the XML data using the candidate path expression,
calculate a cost of executing the one or more database statements in the workload when the index is available (first cost),
calculate a cost of executing the one or more database statements in the workload when the index is not available (second cost),
calculate a cost of maintaining the index with respect to an update, a deletion, or an insertion (third cost), and
subtract from the second cost a sum of the first cost and the third cost to obtain the estimated benefit associated with the candidate path expression.
13. The computer-implemented system of claim 8, wherein the index advisor recommends one or more path expressions from the set of one or more candidate path expressions by:
sorting the set of one or more candidate path expressions according to a benefit-to-size ratio from highest to lowest; and
starting from a highest benefit-to-size ratio candidate path expression, adding a candidate path expression to the set of one or more candidate path expressions in sort order,
unless an index to be created using the candidate path expression will not fit into an available disk space budget, and
until one or more indexes to be created using the set of one or more candidate path expressions will exhaust the available disk budget.
14. The computer-implemented system of claim 8, wherein the index advisor recommends one or more path expressions from the set of one or more candidate path expressions by:
constructing a directed acyclic graph (DAG) using the set of one or more candidate path expressions, each node of the DAG corresponding to one candidate path expression;
selecting one or more nodes of the DAG, wherein candidate path expressions corresponding to the one or more nodes selected are included in the one or more path expressions;
iteratively replacing at least one of the one or more nodes selected with one or more child nodes until one or more indexes to be created using the one or more path expressions corresponding to the one or more child nodes will fit within an available disk budget; and
replacing each candidate path expression included in the set of one or more candidate path expressions corresponding to the at least one of the one or more nodes with the one or more path expressions corresponding to the one or more child nodes replacing the at least one of the one or more nodes.
15. A computer program product comprising a non-transitory computer-readable medium, the computer-readable medium being encoded with a computer program for creating indexes over XML data managed by a database system, wherein the computer program, when executed on a computer, causes the computer to: receive a workload for the XML data, the workload including one or more database statements;
utilize an optimizer of the database system to enumerate a set of one or more candidate path expressions by creating a virtual universal index based on the workload received and matching a path expression to the virtual universal index; and
recommend one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data.
16. The computer program product of claim 15, further wherein the computer program, when executed on the computer, causes the computer to:
generalize the set of one or more candidate path expressions to generate additional candidate path expressions;
utilize the optimizer to estimate a benefit associated with each candidate path expression in relation to the workload received;
utilize the optimizer to estimate a size of an index to be created using each candidate path expression; and
recommend the one or more path expressions from the set of one or more candidate path expressions to create the indexes over the XML data based on at least one of a system constraint, the estimated benefit associated with each candidate path expression, and the estimated size of the index to be created using each candidate path expression.
17. The computer program product of claim 16, wherein generalization of the set of one or more candidate path expressions comprises:
selecting a first candidate path expression and a second candidate path expression;
determining whether the first candidate path expression and the second candidate path expression have one or more common sub-expressions;
responsive to the first candidate path expression and the second candidate path expression having one or more common sub-expressions, returning each of the one or more common sub-expressions as an additional candidate path expression; and
responsive to the first candidate path expression and the second candidate path expression not having one or more common sub-expressions,
modifying each of the first and second candidate path expressions by replacing a last non-* navigating step in each of the first and second candidate path expressions with a* navigation step, and
returning the modified first and second candidate path expressions as the additional candidate path expressions.
18. The computer program product of claim 16, wherein utilization of the optimizer to estimate the benefit associated with each candidate path expression comprises:
sending each candidate path expression to the optimizer for the optimizer to:
estimate a cardinality and a size of an index created over the XML data using the candidate path expression,
calculate a cost of executing the one or more database statements in the workload when the index is available (first cost),
calculate a cost of executing the one or more database statements in the workload when the index is not available (second cost),
calculate a cost of maintaining the index with respect to an update, a deletion, or an insertion (third cost), and
subtract from the second cost a sum of the first cost and the third cost to obtain the estimated benefit associated with the candidate path expression.
19. The computer program product of claim 15 wherein to recommend one or more path expressions from the set of one or more candidate path expressions comprises:
sorting the set of one or more candidate path expressions according to a benefit-to-size ratio from highest to lowest; and
starting from a highest benefit-to-size ratio candidate path expression, adding a candidate path expression to the set of one or more candidate path expressions in sort order,
unless an index to be created using the candidate path expression will not fit into an available disk space budget, and
until one or more indexes to be created using the set of one or more candidate path expressions will exhaust the available disk budget.
20. The computer program product of claim 15, wherein to recommend one or more path expressions from the set of one or more candidate path expressions comprises:
constructing a directed acyclic graph (DAG) using the set of one or more candidate path expressions, each node of the DAG corresponding to one candidate path expression;
selecting one or more nodes of the DAG, wherein candidate path expressions corresponding to the one or more nodes selected are included in the one or more path expressions;
iteratively replacing at least one of the one or more nodes selected with one or more child nodes until one or more indexes to be created using the one or more path expressions corresponding to the one or more child nodes will fit within an available disk budget; and
replacing each candidate path expression included in the set of one or more candidate path expressions corresponding to the at least one of the one or more nodes with the one or more path expressions corresponding to the one or more child nodes replacing the at least one of the one or more nodes.
US13/536,343 2007-08-31 2012-06-28 Index selection for XML database systems Expired - Fee Related US9594783B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US13/536,343 US9594783B2 (en) 2007-08-31 2012-06-28 Index selection for XML database systems

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US11/849,196 US8229920B2 (en) 2007-08-31 2007-08-31 Index selection for XML database systems
US13/536,343 US9594783B2 (en) 2007-08-31 2012-06-28 Index selection for XML database systems

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
US11/849,196 Continuation US8229920B2 (en) 2007-08-31 2007-08-31 Index selection for XML database systems

Publications (2)

Publication Number Publication Date
US20130080441A1 true US20130080441A1 (en) 2013-03-28
US9594783B2 US9594783B2 (en) 2017-03-14

Family

ID=40409019

Family Applications (2)

Application Number Title Priority Date Filing Date
US11/849,196 Expired - Fee Related US8229920B2 (en) 2007-08-31 2007-08-31 Index selection for XML database systems
US13/536,343 Expired - Fee Related US9594783B2 (en) 2007-08-31 2012-06-28 Index selection for XML database systems

Family Applications Before (1)

Application Number Title Priority Date Filing Date
US11/849,196 Expired - Fee Related US8229920B2 (en) 2007-08-31 2007-08-31 Index selection for XML database systems

Country Status (1)

Country Link
US (2) US8229920B2 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9996574B2 (en) 2015-06-30 2018-06-12 International Business Machines Corporation Enhancements for optimizing query executions
US20210064604A1 (en) * 2019-08-28 2021-03-04 Sparta Method, apparatus, and computer readable medium for generating an audit trail of an electronic data record
US11288271B2 (en) * 2020-05-28 2022-03-29 Microsoft Technology Licensing, Llc Data lake workload optimization through explaining and optimizing index recommendations

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8229920B2 (en) 2007-08-31 2012-07-24 International Business Machines Corporation Index selection for XML database systems
US8848924B2 (en) * 2008-06-27 2014-09-30 University Of Washington Privacy-preserving location tracking for devices
ATE535874T1 (en) * 2008-10-01 2011-12-15 Software Ag DATABASE INDEX AND DATABASE FOR INDEXING TEXT DOCUMENTS
CN110019190B (en) * 2017-09-21 2023-05-30 阿里云计算有限公司 Method and device for creating index

Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030225768A1 (en) * 2002-06-03 2003-12-04 Microsoft Corporation Workload analysis tool for relational databases
US20040002957A1 (en) * 2002-06-28 2004-01-01 Microsoft Corporation Linear programming approach to assigning benefit to database physical design structures
US20040003004A1 (en) * 2002-06-28 2004-01-01 Microsoft Corporation Time-bound database tuning
US20040167904A1 (en) * 2003-02-20 2004-08-26 Ji-Rong Wen Semi-structured data storage schema selection
US20040260684A1 (en) * 2003-06-23 2004-12-23 Microsoft Corporation Integrating horizontal partitioning into physical database design
US20040267719A1 (en) * 2003-06-27 2004-12-30 Microsoft Corporation System and method for managed database query pre-optimization
US20050050016A1 (en) * 2003-09-02 2005-03-03 International Business Machines Corporation Selective path signatures for query processing over a hierarchical tagged data structure
US20050203940A1 (en) * 2004-03-12 2005-09-15 Sybase, Inc. Database System with Methodology for Automated Determination and Selection of Optimal Indexes
US20060036989A1 (en) * 2004-08-10 2006-02-16 Microsoft Corporation Dynamic physical database design
US20060053122A1 (en) * 2004-09-09 2006-03-09 Korn Philip R Method for matching XML twigs using index structures and relational query processors
US20060085484A1 (en) * 2004-10-15 2006-04-20 Microsoft Corporation Database tuning advisor
US20060085378A1 (en) * 2004-10-15 2006-04-20 Microsoft Corporation Schema for physical database tuning
US20060242102A1 (en) * 2005-04-21 2006-10-26 Microsoft Corporation Relaxation-based approach to automatic physical database tuning
US20070016604A1 (en) * 2005-07-18 2007-01-18 Ravi Murthy Document level indexes for efficient processing in multiple tiers of a computer system
US20070043696A1 (en) * 2005-08-19 2007-02-22 Haas Peter J Method for estimating the cost of query processing
US20070192280A1 (en) * 2006-02-01 2007-08-16 Microsoft Corporation Sequence based physical design tuning
US7769744B2 (en) * 2005-12-02 2010-08-03 Microsoft Cororation Missing index analysis and index useage statistics

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6539396B1 (en) * 1999-08-31 2003-03-25 Accenture Llp Multi-object identifier system and method for information service pattern environment
US6782380B1 (en) * 2000-04-14 2004-08-24 David Victor Thede Method and system for indexing and searching contents of extensible mark-up language (XML) documents
US7334000B2 (en) * 2001-07-16 2008-02-19 Aol Llc Method and apparatus for calendaring reminders
US7206934B2 (en) * 2002-09-26 2007-04-17 Sun Microsystems, Inc. Distributed indexing of identity information in a peer-to-peer network
KR100558765B1 (en) * 2002-11-14 2006-03-10 한국과학기술원 Method for executing xml query using adaptive path index
US7634498B2 (en) * 2003-10-24 2009-12-15 Microsoft Corporation Indexing XML datatype content system and method
US7512615B2 (en) * 2003-11-07 2009-03-31 International Business Machines Corporation Single pass workload directed clustering of XML documents
US7469249B2 (en) * 2004-03-08 2008-12-23 International Business Machines Corporation Query-driven partial materialization of relational-to-hierarchical mappings
US7228312B2 (en) * 2004-03-09 2007-06-05 Microsoft Corporation Transformation tool for mapping XML to relational database
US7499915B2 (en) * 2004-04-09 2009-03-03 Oracle International Corporation Index for accessing XML data
US7440954B2 (en) * 2004-04-09 2008-10-21 Oracle International Corporation Index maintenance for operations involving indexed XML data
US7493305B2 (en) * 2004-04-09 2009-02-17 Oracle International Corporation Efficient queribility and manageability of an XML index with path subsetting
US7478375B1 (en) * 2004-04-23 2009-01-13 Computer Associates Think, Inc. Directed acyclic graph (DAG) exploration through separation of concerns
US7885980B2 (en) * 2004-07-02 2011-02-08 Oracle International Corporation Mechanism for improving performance on XML over XML data using path subsetting
US7730080B2 (en) * 2006-06-23 2010-06-01 Oracle International Corporation Techniques of rewriting descendant and wildcard XPath using one or more of SQL OR, UNION ALL, and XMLConcat() construct
US8229920B2 (en) 2007-08-31 2012-07-24 International Business Machines Corporation Index selection for XML database systems

Patent Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030225768A1 (en) * 2002-06-03 2003-12-04 Microsoft Corporation Workload analysis tool for relational databases
US20040002957A1 (en) * 2002-06-28 2004-01-01 Microsoft Corporation Linear programming approach to assigning benefit to database physical design structures
US20040003004A1 (en) * 2002-06-28 2004-01-01 Microsoft Corporation Time-bound database tuning
US20040167904A1 (en) * 2003-02-20 2004-08-26 Ji-Rong Wen Semi-structured data storage schema selection
US20040260684A1 (en) * 2003-06-23 2004-12-23 Microsoft Corporation Integrating horizontal partitioning into physical database design
US20040267719A1 (en) * 2003-06-27 2004-12-30 Microsoft Corporation System and method for managed database query pre-optimization
US20050050016A1 (en) * 2003-09-02 2005-03-03 International Business Machines Corporation Selective path signatures for query processing over a hierarchical tagged data structure
US20050203940A1 (en) * 2004-03-12 2005-09-15 Sybase, Inc. Database System with Methodology for Automated Determination and Selection of Optimal Indexes
US20060036989A1 (en) * 2004-08-10 2006-02-16 Microsoft Corporation Dynamic physical database design
US20060053122A1 (en) * 2004-09-09 2006-03-09 Korn Philip R Method for matching XML twigs using index structures and relational query processors
US20060085484A1 (en) * 2004-10-15 2006-04-20 Microsoft Corporation Database tuning advisor
US20060085378A1 (en) * 2004-10-15 2006-04-20 Microsoft Corporation Schema for physical database tuning
US20060242102A1 (en) * 2005-04-21 2006-10-26 Microsoft Corporation Relaxation-based approach to automatic physical database tuning
US20070016604A1 (en) * 2005-07-18 2007-01-18 Ravi Murthy Document level indexes for efficient processing in multiple tiers of a computer system
US20070043696A1 (en) * 2005-08-19 2007-02-22 Haas Peter J Method for estimating the cost of query processing
US7769744B2 (en) * 2005-12-02 2010-08-03 Microsoft Cororation Missing index analysis and index useage statistics
US20070192280A1 (en) * 2006-02-01 2007-08-16 Microsoft Corporation Sequence based physical design tuning

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9996574B2 (en) 2015-06-30 2018-06-12 International Business Machines Corporation Enhancements for optimizing query executions
US10331646B2 (en) 2015-06-30 2019-06-25 International Business Machines Corporation Enhancements for optimizing query executions
US11120000B2 (en) 2015-06-30 2021-09-14 International Business Machines Corporation Enhancements for optimizing query executions
US11163743B2 (en) 2015-06-30 2021-11-02 International Business Machines Corporation Enhancements for optimizing query executions
US20210064604A1 (en) * 2019-08-28 2021-03-04 Sparta Method, apparatus, and computer readable medium for generating an audit trail of an electronic data record
US11675777B2 (en) * 2019-08-28 2023-06-13 Sparta Systems, Inc. Method, apparatus, and computer readable medium for generating an audit trail of an electronic data record
US11288271B2 (en) * 2020-05-28 2022-03-29 Microsoft Technology Licensing, Llc Data lake workload optimization through explaining and optimizing index recommendations

Also Published As

Publication number Publication date
US20090063399A1 (en) 2009-03-05
US9594783B2 (en) 2017-03-14
US8229920B2 (en) 2012-07-24

Similar Documents

Publication Publication Date Title
US9594783B2 (en) Index selection for XML database systems
Do et al. Matching large schemas: Approaches and evaluation
Sakr et al. A framework for querying graph-based business process models
US5544355A (en) Method and apparatus for query optimization in a relational database system having foreign functions
US8086597B2 (en) Between matching
US8984019B2 (en) Scalable summarization of data graphs
Chakaravarthy et al. Efficiently linking text documents with relevant structured information
US20100145902A1 (en) Methods and systems to train models to extract and integrate information from data sources
US7895189B2 (en) Index exploitation
US20080065655A1 (en) Automatically Linking Documents With Relevant Structured Information
US20180075161A1 (en) Extensible automatic query language generator for semantic data
KR100638695B1 (en) Apparatus and method for searching data of structured document
Anadiotis et al. Graph integration of structured, semistructured and unstructured data for data journalism
US20080147598A1 (en) Query optimization using materialized views in database management systems
Agreste et al. XML matchers: approaches and challenges
US11455283B2 (en) Candidate element selection using significance metric values
US7415461B1 (en) Apparatus and method for merging results of approximate matching operations
Zhong et al. Reliable keyword query interpretation on summary graphs
Poulovassilis Applications of flexible querying to graph data
Selvaraj Improving Program Analysis using Efficient Semantic and Deductive Techniques
Halpin Join constraints
Euzenat et al. Overview of matching systems
Hassan Native Graph Support in Relational Data Systems
Elghandour et al. XML index recommendation with tight optimizer coupling
Singh Architecting SQL/PGQ support in DuckDB

Legal Events

Date Code Title Description
AS Assignment

Owner name: INTERNATIONAL BUSINESS MACHINES CORPORATION, NEW Y

Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:ZILIO, DANIELE COSTANTE;REEL/FRAME:039900/0966

Effective date: 20160928

STCF Information on status: patent grant

Free format text: PATENTED CASE

FEPP Fee payment procedure

Free format text: MAINTENANCE FEE REMINDER MAILED (ORIGINAL EVENT CODE: REM.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY

LAPS Lapse for failure to pay maintenance fees

Free format text: PATENT EXPIRED FOR FAILURE TO PAY MAINTENANCE FEES (ORIGINAL EVENT CODE: EXP.); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY

STCH Information on status: patent discontinuation

Free format text: PATENT EXPIRED DUE TO NONPAYMENT OF MAINTENANCE FEES UNDER 37 CFR 1.362

FP Lapsed due to failure to pay maintenance fee

Effective date: 20210314