Method and apparatus for reordering complex SQL queries containing inner and outer join operations
First Claim
1. A method of reordering a query in a computer having a memory, the query being used by the computer to direct information retrieval from a relational database stored in an electronic storage device coupled to the computer, the method comprising the steps of:
- (a) accepting the query into the memory of the computer;
(b) enumerating one or more plans for the query in the memory of the computer, wherein the enumerated plans represent associative re-orderings of relations in the query; and
(c) selectively assigning a Modified General Outer Join (MGOJ) operator at a root of one or more of the enumerated plans.
0 Assignments
0 Petitions
Accused Products
Abstract
A method and apparatus for reordering complex SQL queries containing joins, outer and full outer joins. The method and apparatus first translates the query into a hypergraph representation. Required sets, conflict sets and preserved sets are then generated for the query hypergraph. Using the required sets, a plurality of plans are enumerated, wherein the plans represent associative re-orderings of relations in the query. SQL operators are selectively assigned to each of the enumerated plans using the conflict sets and/or preserved sets, so that the results from the plans are identical to the original query. A novel Modified General Outer Join (MGOJ) operator may be assigned to the root of a sub-tree, wherein the MGOJ operator is a compensation operator. The operator assignment is performed recursively for the root of each sub-tree in the plan. One of the enumerated plans (generally the most optimal) is then selected for execution.
-
Citations
24 Claims
-
1. A method of reordering a query in a computer having a memory, the query being used by the computer to direct information retrieval from a relational database stored in an electronic storage device coupled to the computer, the method comprising the steps of:
-
(a) accepting the query into the memory of the computer; (b) enumerating one or more plans for the query in the memory of the computer, wherein the enumerated plans represent associative re-orderings of relations in the query; and (c) selectively assigning a Modified General Outer Join (MGOJ) operator at a root of one or more of the enumerated plans. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. An apparatus for reordering a query, comprising:
(a) a computer having a memory, the query being used by the computer to direct information retrieval from a relational database stored in an electronic storage device coupled to the computer, the computer further comprising; (1) means for accepting the query into the memory of the computer; (2) means for enumerating one or more plans for the query in the memory of the computer, wherein the enumerated plans represent associative re-orderings of relations in the query; and (3) means for selectively assigning a Modified General Outer Join (MGOJ) operator at a root of one or more of the enumerated plans. - View Dependent Claims (10, 11, 12, 13, 14, 15, 16)
-
17. A program storage device, readable by a computer, tangibly embodying a program of instructions executable by the computer to perform method steps reordering a query in a computer having a memory, the query being used by the computer to direct information retrieval from a relational database stored in an electronic storage device coupled to the computer, the method comprising the steps of:
-
(a) accepting the query into the memory of the computer; (b) enumerating one or more plans for the query in the memory of the computer, wherein the enumerated plans represent associative re-orderings of relations in the query; and (c) selectively assigning a Modified General Outer Join (MGOJ) operator at a root of one or more of the enumerated plans. - View Dependent Claims (18, 19, 20, 21, 22, 23, 24)
-
Specification