Automatic tuning of database queries
AssigneeBusiness Objects Software Ltd.
InventorJoseph Wong
Life of this patent
Estimating the term…
Abstract
A database query is modified to improve performance by identifying portions of database tables that are likely to be reused and modifying the database query accordingly. According to certain embodiments, the degree of selectivity with which a table is accessed is used to identify tables that are likely to be reused in subsequent database operations.
Claims30
A method of opt a database query, the method comprising:
- accessing a first database query, the first database query including selection operations directed to one or more tables in a database;
- determining a first hierarchical tree that corresponds to the first database query, the first hierarchical tree including at least one source node for each of the one or more tables in the first database query;
- identifying to source node of the first hierarchal tree as highly selective if a selectivity condition is satisfied by a corresponding table for the source node or as not highly selective if the selectivity condition is not satisfied by the corresponding table for the source node, the selectivity condition corresponding to a limit on a number of rows accessed in the corresponding table;
- determining a second hierarchical tree from the first hierarchal tree by replacing the source node with a sub-tree that corresponds to a filtered selection of the corresponding table from a larger table in the database, the sub-tree including an intermediate table that characterizes the filtered selection from the larger table if the source node is identified as not highly selective, and the sub-tree not including an intermediate table that characterizes the filtered selection from the larger table if the corresponding source node is identified as highly selective;
- and
- determining a second database query that corresponds to the second hierarchical tree.
A non-transitory computer-readable medium that stores a computer program for optimizing a database query, the computer program including instructions that, when executed by at least one computer, cause the at least one computer to perform operations comprising:
- accessing a first database query, the first database query including selection operations directed to one or more tables in a database;
- determining a first hierarchical tree that corresponds to the first database query, the first hierarchical tree. Including at least one source node for each of the one or more tables in the first database query;
- identifying a source node of the first hierarchal tree as highly selective if a selectivity condition is satisfied by a corresponding table for the source node or as not highly selective if the selectivity condition is not satisfied by the corresponding table for the source node, the selectivity condition corresponding to a limit on a number of rows accessed in the corresponding table;
- determining a second hierarchical tree, from the first hierarchal tree by replacing the source node with a sub-tree that corresponds to a filtered selection of the corresponding table from a larger table in the database, the sub-tree including an intermediate table that characterizes the filtered selection from the larger table if the source node is identified as not highly selective, and the sob-tree not including an intermediate table that characterizes the filtered selection from the larger table if the corresponding source node is identified as highly selective;
- and
- determining a second database query that corresponds to the second hierarchical tree.
An apparatus configured to optimize a database query, the apparatus comprising at least one computer configured to perform operations for computer-implemented modules including:
- a query-access module that accesses a first database query, the first database query including selection operations directed to one or more tables in a database;
- a tree-determination module that determines a first hierarchical tree that corresponds to the first database query, the first hierarchical tree including at least one source node for each of the one or more tables in the first database query;
- a selectivity-identification module that identities a source node of the first hierarchal tree as highly selective if a selectivity condition is satisfied by a corresponding table for the source node or as not highly selective if the selectivity condition is not satisfied by the corresponding table for the source node, the selectivity condition corresponding to a limit on a number of rows accessed in the corresponding table;
- a node-replacement module that determines a second hierarchical tree from the first hierarchal tree by replacing the source node with a sub-tree that corresponds to a filtered selection of the corresponding table from a larger table in the database, the sub-tree including an intermediate table that characterizes the filtered selection from the larger table if the source node is identified as not highly selective, and the sub-tree not including an intermediate table that characterizes the filtered selection from the larger table it the corresponding source node is identified as highly selective;
- and
- a query-determination module that determines a second database query that corresponds to the second hierarchical tree.
Dependencies are inferred from the claim text.