Claims
- 1. A method of reordering a query in a computer having a memory wherein the query has a plurality of relations and at least one binary operator amongst two or more of the relations, and wherein the query is performed by the computer to retrieve data from a data storage device connected to the computer comprising the steps of:
- (a) determining a generalized selection (GS) operator for the query relations; and
- (b) using the GS operator to obtain a query result.
- 2. The method of claim 1, the query further having a unary operator amongst two or more of the relations, the determining step further comprising the steps of:
- analyzing the unary and binary operators between the relations to determine the need to evaluate the GS operator; and
- if the GS operator is-needed, computing the GS operator.
- 3. The method of claim 1, wherein the GS operator, .sigma..sup.*.sub.p �r.sub.2,r.sub.3 ! (r.sub.1), of relation r.sub.1 with respect to relations r.sub.2 and r.sub.3 comprises the relation (R.sub.1,V.sub.1,E.sup.1), wherein:
- E.sup.1 =.sigma..sub.p (r.sub.1) {.pi..sub.R.sup.c.sbsb.2.sub.V.sbsb.2 (r.sub.1)-.pi..sub.R.sup.c.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (r.sub.1)-.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (.sigma..sub.p (r.sub.1))}
- and wherein r.sub.1 =(R.sub.1,V.sub.1,E.sub.1), r.sub.2 =(R.sub.2,V.sub.2,E.sub.2), and r.sub.3 =(R.sub.3, V.sub.3,E.sub.3) comprise three relations such that R.sub.2 .OR right.R.sub.1, R.sub.3 .OR right.R.sub.1, R.sub.2 .andgate.R.sub.3 =.phi., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.phi., and p denotes a null-intolerant predicate in R.sub.1.
- 4. An apparatus for reordering a query having a plurality of relations and at least one binary operator amongst two or more of the relations, comprising:
- (a) means for determining a generalized selection (GS) operator for the query relations; and
- (b) means for using the GS operator to obtain a query result.
- 5. The apparatus of claim 4, the query further having a unary operator amongst two or more of the relations, the means for determining further comprising:
- means for analyzing the unary and binary operators between the relations to determine the need to evaluate the GS operator; and
- means for computing the GS operator, if the GS operator is needed.
- 6. The apparatus of claim 4, wherein the GS operator, .sigma..sub.p.sup.* �r.sub.2, r.sub.3 !(r.sub.1), of relation r.sub.1 with respect to relations r.sub.2 and r.sub.3 comprises the relation (R.sub.1,V.sub.1, E.sup.1), wherein:
- e.sup.1 =.sigma..sub.p (r.sub.1) {.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (r.sub.1)-.pi..sub.R.sbsb.2.sup.c.sub.v.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (r.sub.1)-.pi..sub.R.sbsb.3.sup.c.sub.v.sbsb.3 (.sigma..sub.p (r.sub.1))}
- and wherein r.sub.1 =(R.sub.1,V.sub.1, E.sub.1), r.sub.2 (R.sub.2, V.sub.2,E.sub.2), and r.sub.3 =(R.sub.3, V.sub.3 E.sub.3) comprise three relations such that R.sub.2 .OR right.R.sub.1, R.sub.3 .OR right.R.sub.1, R.sub.2 .andgate.R.sub.3 =.phi., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.phi., and p denotes a null-intolerant predicate in R.sub.1.
- 7. An article of manufacture comprising a computer program carrier embodying one or more instructions of a method of reordering a query having a plurality of relations and at least one binary operator amongst two or more of the relations, comprising the steps of:
- (a) determining a generalized selection (GS) operator for the query relations; and
- (b) using the GS operator to obtain a query result.
- 8. The article of manufacture of claim 7, the query further having a unary operator amongst two or more of the relations, the determining step further comprising the steps of:
- analyzing the unary and binary operators between the relations to determine the need to evaluate the GS operator; and
- if the GS operator is needed, computing the GS operator.
- 9. The article of manufacture of claim 7, wherein the GS operator, .sigma..sub.p.sup.* �r.sub.2,r.sub.3 ! (r.sub.1), of relation r.sub.1 with respect to relations r.sub.2 and r.sub.3 comprises the relation (R.sub.1,V.sub.1, E.sup.1), wherein:
- E.sup.1 =.sigma..sub.p (r.sub.1) {.pi..sub.R.sbsb.2.sup.c.sub.v.sbsb.2 (r.sub.1)-.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (r.sub.1)-.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (.sigma..sub.p (r.sub.1))}
- and wherein r.sub.1 =(R.sub.1, V.sub.1,E.sub.1), r.sub.2 =(R.sub.2, V.sub.2,E.sub.2), and r.sub.3 =(R.sub.3,V.sub.3,E.sub.3) comprise three relations such that R.sub.2 .OR right.R.sub.1, R.sub.3 .OR right.R.sub.1, R.sub.2 .andgate.R.sub.3 =.phi., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.phi., and p denotes a null-intolerant predicate in R.sub.1.
- 10. A method of computing an outer join between two or more relations in a query that is performed in a memorv of a computer to retrieve data from a data storage device, comprising the steps of:
- (a) determining a generalized selection (GS) operator for the relations; and
- (b) applying the GS operator to a cross product of the relations.
- 11. The method of claim 10, wherein the GS operator, .sigma..sub.p.sup.* �r.sub.2, r.sub.3 !(r.sub.1), of relation r.sub.1 with respect to relations r.sub.2 and r.sub.3 comprises the relation (R.sub.1, V.sub.1,E.sup.1, wherein:
- E.sup.1 =.sigma..sub.p (r.sub.1) {.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (r.sub.1)-.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (r.sub.1)-.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (.sigma..sub.p (r.sub.1))}
- and wherein r.sub.1 =(R.sub.1,V.sub.1,E.sub.1), r.sub.2 =(R.sub.2,V.sub.2,E.sub.2), and r.sub.3 =(R.sub.3,V.sub.3, E.sub.3) comprise three relations such that R.sub.2 .OR right.R.sub.1, R.sub.3 .OR right.R.sub.1, R.sub.2 .andgate.R.sub.3 =.phi., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =100, and p denotes a null-intolerant predicate in R.sub.1.
- 12. An apparatus for computing an outer join between two or more relations in a query, comprising:
- (a) means for determining a generalized selection (GS) operator for the relations; and
- (b) means for applying the GS operator to a cross product of the relations.
- 13. The apparatus of claim 12, wherein the GS operator, .sigma..sub.p.sup.* �r.sub.2, r.sub.3 !(r.sub.1), of relation r.sub.1 with respect to relations r.sub.2 and r.sub.3 comprises the relation (R.sub.1,V.sub.1,E.sup.1) wherein:
- E.sup.1 =.sigma..sub.p (r.sub.1) {.pi..sub.R.sbsb.2.sup.c.sub.v.sbsb.2 (r.sub.1)-.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sub.R.sbsb.3.sup.c.sub.v.sbsb.3 (r.sub.1)-.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (.sigma..sub.p (r.sub.1)) }
- and wherein r.sub.1 =(R.sub.1, V.sub.1,E.sub.1), r.sub.2 =(R.sub.2, V.sub.2,E.sub.2), and r.sub.3 =(R.sub.3,V.sub.3,E.sub.3) comprise three relations such that R.sub.2 .OR right.R.sub.1, R.sub.3 .OR right.R.sub.1, R.sub.2 .andgate.R.sub.3 =.phi., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.phi., and p denotes a null-intolerant predicate in R.sub.1.
- 14. An article of manufacture comprising a computer program carrier embodying one or more instructions of a method of computing an outer join between two or more relations in a query, the method comprising the steps of:
- (a) determining a generalized selection (GS) operator for the relations; and
- (b) applying the GS operator to a cross product of the relations.
- 15. The article of manufacture of claim 14, wherein the GS operator, .sigma..sub.p.sup.* �r.sub.2,r.sub.3 !(r.sub.1) , of relation r.sub.1 with respect to relations r.sub.2 and r.sub.3 comprises the relation (R.sub.1,V.sub.1,E.sup.1), wherein:
- E.sup.1 =.sigma..sub.p (r.sub.1) {.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (r.sub.1)-.pi..sub.R.sbsb.2.sup.c.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (r.sub.1)-.pi..sub.R.sbsb.3.sup.c.sub.V.sbsb.3 (.sigma..sub.p (r.sub.1))}
- and wherein r.sub.1 =(R.sub.1,V.sub.1,E.sub.1), r.sub.2 =(R.sub.2,V.sub.2,E.sub.2), and r.sub.3 =(R.sub.3, V.sub.3 E.sub.3) comprise three relations such that R.sub.2 .OR right.R.sub.1, R.sub.3 .OR right.R.sub.1, R.sub.2 .andgate.R.sub.3 =.phi., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.phi., and p denotes a null-intolerant predicate in R.sub.1.
CROSS-REFERENCE TO RELATED APPLICATION
This application is a continuation of commonly-assigned patent application Ser. No. 08/655,300, filed May 30, 1996, which issued as U.S. Pat. No. 5,713,015 on Jan. 28, 1998, by Piyush Goel, et al., and entitled "REORDERING OF COMPLEX SQL QUERIES INVOLVING GROUPBYS, JOINS, OUTER JOINS AND FULL OUTER JOINS," which application is incorporated by reference herein.
US Referenced Citations (9)
Non-Patent Literature Citations (2)
Entry |
Gautam Bhargava et al., "Efficient Processing of Outer Joins and Aggregate Functions," 1996, 12th International Conference on Data Engineering, IEEE, pp. 441-449. |
Pintsang Chang, "Nonlinear Versus Linear Resursion: A Perspective from Computing Transitive Closure of a Binary Relation by the Join Domain Nested loops Approach", 1990, Compsac, pp. 382-390. |
Continuations (1)
|
Number |
Date |
Country |
Parent |
655300 |
May 1996 |
|