Claims
- 1. A method of simplifying a query performed by a computer to retrieve data from a relational database stored in a electronic storage device coupled to the computer, the method comprising the steps of:
- (a) eliminating redundant sub-expressions from the query and modifying expensive binary operations in the query to inexpensive binary operations, so that only simple and complex predicates remain in the query; and
- (b) converting the complex predicates remaining in the query to simple predicates by application of a generalized selection (GS) operator.
- 2. The method of claim 1, further comprising the step of applying a simplification identity to a SELECT DISTINCT operator in the query.
- 3. The method of claim 1, further comprising the step of applying a simplification identity for a push-up of a GROUPBY operator in the query.
- 4. 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'), wherein:
- E'=.sigma..sub.p (r.sub.1){.pi..sup.c.sub.R.sbsb.2.sub.V.sbsb.2 (r.sub.1)-.pi..sup.c.sub.R.sbsb.2.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))} {.pi..sup.c.sub.R.sbsb.3.sub.V.sbsb.3 (r.sub.1)-.pi..sup.c.sub.R.sbsb.3.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 =.o slashed., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.o slashed., and p denotes a null-intolerant predicate in R.sub.1.
- 5. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU22## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 6. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU23## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 7. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU24##
- where .circle-w/dot..di-elect cons.{.fwdarw., .rarw., .revreaction.}wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 8. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU25##
- where .circle-w/dot..di-elect cons.{.fwdarw., .rarw., .revreaction.}
- wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 9. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU26## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 10. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU27## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 11. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU28## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 12. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU29## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 13. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU30## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 14. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU31## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 15. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU32## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 16. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU33## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 17. The method of claim 1, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU34## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 18. An apparatus for simplifying a query performed by a computer to retrieve data from a relational database stored in a electronic storage device, comprising:
- (a) means for eliminating redundant sub-expressions from the query and modifying expensive binary operations in the query to inexpensive binary operations, so that only simple and complex predicates remain in the query; and
- (b) means for converting the complex predicates remaining in the query to simple predicates by application of a generalized selection (GS) operator.
- 19. The apparatus of claim 18, further comprising means for applying a simplification identity to a SELECT DISTINCT operator in the query.
- 20. The apparatus of claim 18, further comprising means for applying a simplification identity for a push-up of a GROUPBY operator in the query.
- 21. The apparatus of claim 18, 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'), wherein:
- E'=.sigma..sub.p (r.sub.1){.pi..sup.c.sub.R.sbsb.2.sub.V.sbsb.2 (r.sub.1)-.pi..sup.c.sub.R.sbsb.2.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))}{.pi..sup.c.sub.R.sbsb.3.sub.V.sbsb.3 (r.sub.1)-.pi..sup.c.sub.R.sbsb.3.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 =.o slashed., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.o slashed., and p denotes a null-intolerant predicate in R.sub.1.
- 22. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU35## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 23. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU36## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 24. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU37##
- where .circle-w/dot..di-elect cons.{, .fwdarw., .rarw., .revreaction.}wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 25. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU38##
- where .circle-w/dot..di-elect cons.{, .fwdarw., .rarw., .revreaction.}wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 26. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU39## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 27. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU40## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 28. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU41## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 29. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU42## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 30. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU43## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 31. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU44## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 32. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU45## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 33. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU46## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 34. The apparatus of claim 18, wherein the means for converting comprises means for applying a simplification expression to the query comprising: ##EQU47## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 35. An article of manufacture comprising a computer program carrier embodying one or more instructions of a method of simplifying a query performed by a computer to retrieve data from a relational database stored in a electronic storage device, the method comprising the steps of:
- (a) eliminating redundant sub-expressions from the query and modifying expensive binary operations in the query to inexpensive binary operations, so that only simple and complex predicates remain in the query; and
- (b) converting the complex predicates remaining in the query to simple predicates by application of a generalized selection (GS) operator.
- 36. The article of manufacture of claim 35, wherein the method further comprises the step of applying a simplification identity to a SELECT DISTINCT operator in the query.
- 37. The article of manufacture of claim 35, wherein the method further comprises the step of applying a simplification identity for a push-up of a GROUPBY operator in the query.
- 38. The article of manufacture of claim 35, 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'), wherein:
- E'=.sigma..sub.p (r.sub.1){.pi..sup.c.sub.R.sbsb.2.sub.V.sbsb.2 (r.sub.1)-.pi..sup.c.sub.R.sbsb.2.sub.V.sbsb.2 (.sigma..sub.p (r.sub.1))}{.pi..sup.c.sub.R.sbsb.3.sub.V.sbsb.3 (r.sub.1)-.pi..sup.c.sub.R.sbsb.3.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 =.o slashed., V.sub.2 .OR right.V.sub.1, V.sub.3 .OR right.V.sub.1, and V.sub.2 .andgate.V.sub.3 =.o slashed., and p denotes a null-intolerant predicate in R.sub.1.
- 39. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU48## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 40. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU49## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 41. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU50##
- where .circle-w/dot..di-elect cons.{, .fwdarw., .rarw., .revreaction.}wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 42. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU51##
- where .circle-w/dot..di-elect cons.{, .fwdarw., .rarw., .revreaction.}wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 43. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU52## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 44. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU53## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 45. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU54## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 46. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU55## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 47. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU56## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 48. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU57## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 49. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU58## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 50. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU59## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
- 51. The article of manufacture of claim 35, wherein the converting step comprises the step of applying a simplification expression to the query comprising: ##EQU60## wherein X.sub.i =(R.sub.i, V.sub.i, E.sub.i) are relational expressions for 1.ltoreq.i.ltoreq.3, and p.sub.i,j denote the predicates between expressions X.sub.i and X.sub.j.
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 is incorporated by reference herein.
US Referenced Citations (5)
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 Recursion: A Perspective from Computing Transitive Closures 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 |
|