Method and apparatus for reordering complex SQL queries using a modified generalized outer join operator
First Claim
1. A method of reordering an SQL query in a computer having a memory, comprising the steps of:
- (a) accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU51## (b) replacing the first expression with a second expression comprising;
##EQU52## wherein the MGOJ operator comprises a relation (R1,2 R3,V1,2 V3,E'"'"') and the second expression preserves relation X1, wherein;
##EQU53## wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples in the relation R1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples in the relation r3, ##EQU54## Pi,j is a predicate for ##EQU55## and π
c denotes a projection operation.
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 reorderings 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
9 Claims
-
1. A method of reordering an SQL query in a computer having a memory, comprising the steps of:
-
(a) accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU51## (b) replacing the first expression with a second expression comprising;
##EQU52## wherein the MGOJ operator comprises a relation (R1,2 R3,V1,2 V3,E'"'"') and the second expression preserves relation X1, wherein;
##EQU53## wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples in the relation R1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples in the relation r3, ##EQU54## Pi,j is a predicate for ##EQU55## and π
c denotes a projection operation.
-
-
2. A method of reordering an SQL query in a computer having a memory, comprising the steps of:
-
(a) accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU56## (b) replacing the first expression with a second expression comprising;
##EQU57## wherein the MGOJ operator comprises a relation (R1,2 R3,V1,2 V3,E'"'"') and the second expression preserves relation X1, wherein;
##EQU58## wherein R1,2 is a nonempty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples for the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples for the relation r3, ##EQU59## pi,j is a predicate for ##EQU60## and π
c denotes a projection operation.
-
-
3. A method of reordering an SQL query in a computer having a memory, comprising the steps of:
-
(a) accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU61## (b) replacing the first expression with a second expression comprising;
##EQU62## wherein the MGOJ operator comprises a relation (R1 R2, V1 V2,E'"'"') and the second expression preserves relations X1 and X3, wherein;
##EQU63## wherein R1,2 is a nonempty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples for the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples for the relation r3, R1,2 ∩
R3 =.o slashed.,V1,2 ∩
V3 =.o slashed.,X1 =(R1,V1,E1) X1 and X3 are relations such that ##EQU64## Pi,j is a predicate for ##EQU65## and π
c denotes a projection operation.
-
-
4. A program storage device readable by a computer, tangibly embodying a program of instructions executable by the computer to perform method steps for reordering an SQL query in the method comprising the steps of:
-
(a) accepting a query into the computer, wherein a first expression of the query comprises;
##EQU66## (b) replacing the first expression with a second expression comprising;
##EQU67## wherein the MGOJ operator comprises a relation (R1,2 R3,V1,2 V3,E'"'"') and the second expression preserves relation X1, wherein;r1,2 =(X1→
P1,2 X2)=(R1,2,V1,2,E1,2), wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples in the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples in the relation r3, ##EQU68## Pi,j is a predicate for ##EQU69## and π
c denotes a projection operation.
-
-
5. A program storage device readable by a computer having a memory, tangibly embodying a program of instructions executable by the computer to perform method steps for reordering an SQL query, the method comprising the steps of:
-
(a) accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU70## (b) replacing the first expression with a second expression comprising;
##EQU71## wherein the MGOJ operator comprises a relation and the second expression preserves relationwherein; r1,2 =(X1⃡
P.sbsp.1,2 X2)=(R1,2,V1,2,E1,2), wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples for the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples for the relation r3, ##EQU72## Pi,j is a predicate for ##EQU73## and π
c denotes a projection operation.
-
-
6. A program storage device readable by a computer having a memory, tangibly embodying a program of instructions executable by the computer to perform method steps for reordering an SQL query, the method comprising the steps of:
-
(a) accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU74## (b) replacing the first expression with a second expression comprising;
##EQU75## wherein the MGOJ operator comprises a relation (R1 R2,V1 V1,E'"'"') and the second expression preserves relations X1 and X3, wherein;
##EQU76## wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a relation r1,2,r3 =X3 =(R3,V3,E3), wherein real attributes, V3 is a non-attributes, and E3 is a set R1,2 ∩
R3 =.o slashed.,V1,2 ∩
V3 =.o slashed.,X1 =(R1,V1,E1), X1 and X3 are relations such that ##EQU77## Pi,j is a predicate for ##EQU78## and π
c denotes a projection operation.
-
-
7. An apparatus for reordering an SQL query, comprising:
-
a computer having a memory, wherein the SQL query is used by the computer to direct information retrieval from a relational database stored in an electronic storage device in communication with the computer, the computer further comprising; means for accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU79## means for replacing the first expression with a second expression comprising;
##EQU80## wherein the MGOJ operator comprises a relation (R1,2 R3,V1,2 V3,E'"'"') and the second expression preserves relation X1, wherein;
##EQU81## wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples in the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples in the relation r3, ##EQU82## Pi,j is a predicate for ##EQU83## and π
c denotes a projection operation.
-
-
8. An apparatus for reordering an SQL query, comprising:
-
a computer having a memory, wherein the SQL query is used by the computer to direct information retrieval from a relational database stored in an electronic storage device in communication with the computer, the computer further comprising; means for accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU84## means for replacing the first expression with a second expression comprising;
##EQU85## wherein the MGOJ operator comprises a relation (R1,2 R3,V1,2 V3,E'"'"') and the second expression preserves relation X1, wherein;
##EQU86## wherein R1,2 is a nonempty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples for the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples for the relation r3, ##EQU87## pi,j is a predicate for ##EQU88## and π
c denotes a projection operation.
-
-
9. An apparatus for reordering an SQL query, comprising:
-
a computer having a memory, wherein the SQL query is used by the computer to direct information retrieval from a relational database stored in an electronic storage device in communication with the computer, the computer further comprising; means for accepting a query into the memory of the computer, wherein a first expression of the query comprises;
##EQU89## means for replacing the first expression with a second expression comprising;
##EQU90## wherein the MGOJ operator comprises a relation (R1 R2,V1 V2,E'"'"') and the second expression preserves relations X1 and X3, wherein;
##EQU91## wherein R1,2 is a non-empty set of real attributes, V1,2 is a non-empty set of virtual attributes, and E1,2 is a set of tuples for the relation r1,2,r3 =X3 =(R3,V3,E3), wherein R3 is a non-empty set of real attributes, V3 is a non-empty set of virtual attributes, and E3 is a set of tuples for the relation r3, R1,2 ∩
R3 =.o slashed.,V1,2 ∩
V3 =.o slashed.,X1 =(R1,V1,E1), X1 and X3 are relations such that Rx.sbsb.1 ∩
Rx.sbsb.3 =Vx.sbsb.1 ∩
Vx.sbsb.3 =.o slashed.,Rx.sbsb.1 .OR right.R1,2 and Rx.sbsb.3 .OR right.R1,2, ##EQU92## pi,j is a predicate for ##EQU93## and π
c denotes a projection operation.
-
Specification