Method for detecting and optimizing queries with encoding/decoding tables
First Claim
1. In a relational database management system including a data processor, a stored database, and a plurality of database relations stored in the form of tables, wherein one or more of said relations are retrieved by the processor responsive to a query statement which specifies desired relations, the query statement including first, second, and third tables, and further including a join predicate between relations of the first and second tables and a join predicate between relations of the first and third tables, but not including a join predicate between the relations of the first and third tables, the system producing first plans for performing a plurality of join operations on the desired relations, an optimizing module for use in optimizing query commands, the optimizing module comprising:
- means for determining that the first table referenced in the query statement is a hub table, and for determining that the second and third tables are spoke tables associated with the hub table because of the respective join predicates therebetween;
means, operable responsive to identification of the hub table, for constructing a second plan for joining the hub table and the associated spoke tables;
means for generating a third plan for joining the second and third tables of the desired relations referenced in said query statement; and
means for enumerating the first, second, and third plans to determine the best plan for joining said tables referenced in said query statement.
0 Assignments
0 Petitions
Accused Products
Abstract
A join optimizer and method for a relational database management system including a data processor, a stored database, and a plurality of database relations, wherein one or more of the relations are retrieved by the processor by means of query commands by performing a plurality of join operations on the relations, the system employing a general purpose heuristic algorithm which excludes or defers Cartesian products as late in the join sequence as possible, the method includes the steps of determining, in association with the execution of, or preferably prior to executing the general purpose algorithm, whether tables referenced in a query command includes a hub table and at least two encoding tables related to the hub table and, when the query command references a hub table and at least two encoding tables, determining the best access plan for the hub table, determining whether the best access plan utilizes an index used to access the hub table and, if so, constructing a plan to join the encoding tables as Cartesian products, constructing a plan to join the hub table and the encoding tables and storing the plans in the data structures of the optimizer for enumeration with other access plans constructed by the optimizer.
-
Citations
15 Claims
-
1. In a relational database management system including a data processor, a stored database, and a plurality of database relations stored in the form of tables, wherein one or more of said relations are retrieved by the processor responsive to a query statement which specifies desired relations, the query statement including first, second, and third tables, and further including a join predicate between relations of the first and second tables and a join predicate between relations of the first and third tables, but not including a join predicate between the relations of the first and third tables, the system producing first plans for performing a plurality of join operations on the desired relations, an optimizing module for use in optimizing query commands, the optimizing module comprising:
-
means for determining that the first table referenced in the query statement is a hub table, and for determining that the second and third tables are spoke tables associated with the hub table because of the respective join predicates therebetween; means, operable responsive to identification of the hub table, for constructing a second plan for joining the hub table and the associated spoke tables; means for generating a third plan for joining the second and third tables of the desired relations referenced in said query statement; and means for enumerating the first, second, and third plans to determine the best plan for joining said tables referenced in said query statement. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. For use by a relational database management system, the system including a data processor, a stored database, and a plurality of database relations, wherein one or more of said relations are retrieved by the processor by means of a query command, the query command including first, second, and third tables, and further including a join predicate between relations of the first and second tables and a join predicate between relations of the first and third tables, but not including a join predicate between the relations of the first and third tables, by performing a plurality of join operations on said relations, the system further including an optimizer for optimizing the query command, the optimizer employing a general purpose heuristic algorithm which excludes or defers Cartesian products as late in the join sequence as possible, a method comprising the steps of:
-
in association with the execution of said general purpose algorithm, determining that the first table referenced in the query command includes a hub table, and for determining that the second and third tables are related to said hub table as encoding tables because of the respective join predicates therebetween; and responsive to the query command referencing a hub table and at least two encoding tables, performing the steps of; (i) determining the best access plan for said hub table, (ii) determining whether said best access plan utilizes an index used to access said hub table, (iii) if so, constructing a plan to join said encoding tables as Cartesian products, (iv) constructing a plan to join said hub table and said encoding tables, and (v) storing said plans in the data structures of said optimizer for enumeration with other access plans constructed by said optimizer. - View Dependent Claims (8, 9, 10, 13)
-
-
11. For use by a relational database management system including a data processor, a stored database, and a plurality of database relations, wherein one or more of said relations are retrieved by the processor by means of a query command, the query command including first, second, and third tables, and further including a join predicate between relations of the first and second tables and a join predicate between relations of the first and third tables, but not including a join predicate between the relations of the first and third tables, by performing a plurality of join operations on said relations, the system further including an optimizer for optimizing the query command, the optimizer employing a general purpose heuristic algorithm which excludes or defers Cartesian products as late in the join sequence as possible, a method comprising the steps of:
-
in association with the execution of said general purpose algorithm, determining that the first table referenced in the query command includes a hub table and for determining that the second and third tables are related to said hub table as encoding tables because of the respective join predicates therebetween, the step of determining including; (i) the step, executed for each table referenced in said query command, of counting the number of tables which are joined to the referenced table by join predicates, and (ii) the step of storing the identity of the table having the largest number of tables joined to it and the magnitude of said largest number; responsive to the query command referencing a hub table and at least two encoding tables, (i) determining the best access plan for said hub table, (ii) determining whether said best access plan utilizes an index used to access said hub table and, if so; (a) for each index of said hub table and for each column of the index, determining the join predicates which link said column to one of said encoding tables, and applying said join predicates as local predicates, using said column of said index, to access those rows of said table which satisfy the join predicates in the query statement; (b) constructing a plan to join said encoding tables as Cartesian products; (c) constructing a plan to join said hub table and said encoding tables; and (d) storing said plans in the data structures of said optimizer for enumeration with other access plans constructed by said optimizer. - View Dependent Claims (14)
-
-
12. For use by a relational database management system, the system including a data processor, a stored database, and a plurality of database relations, wherein one or more of said relations are retrieved by the processor by means of a query command, the query command including first, second, and third tables, and further including a join predicate between relations of the first and second tables and a join predicate between relations of the first and third tables, but not including a join predicate between the relations of the first and third tables, by performing a plurality of join operations on said relations, the system further including an optimizer for optimizing query commands and which employs a general purpose heuristic algorithm which excludes or defers Cartesian products as late in the join sequence as possible, the improvement comprising the steps of:
-
in association with the execution of said general purpose algorithm, determining whether the first table specified in the query command includes a hub table, and further determining whether the second and third tables specified in the query command include two tables related to the hub table as encoding tables because of the respective join predicates therebetween; and when said tables include two or more encoding tables, executing the steps of; (i) determining a best access plan for said table related to two or more encoding tables when said tables includes two or more encoding tables; (ii) determining whether said best access plan employs an index used to access said table related to two or more encoding tables; and (iii) if so, executing the steps of; (a) constructing a plan to join said encoding tables as a first Cartesian product; (b) constructing a plan to join said table related to two encoding tables; and (c) storing each said plan in the data structures of said optimizer for enumeration with other plans constructed by said optimizer. - View Dependent Claims (15)
-
Specification