×

System and method for database query optimization

  • US 5,819,255 A
  • Filed: 12/27/1996
  • Issued: 10/06/1998
  • Est. Priority Date: 08/23/1996
  • Status: Expired due to Term
First Claim
Patent Images

1. A computer-implemented method for generating a plan for executing a database query, comprising:

  • (a) representing said database query as a query tree including one or more levels of logical expressions, each logical expression including zero or more logical expressions as inputs, a subset of said inputs representing one or more subtrees, each subtree having a top logical expression and zero or more logical expressions as inputs, each level other than a top level having one or more logical expressions that are input to a higher level logical expression at a preceding level, one of said logical expressions representing a root expression, each logical expression including zero or more inputs and zero or more outputs;

    (b) for each said logical expression in said query tree, determining group attributes for each said logical expression, said group attributes including a set of characteristic inputs and a set of characteristic outputs, said characteristic inputs representing inputs required for a particular logical expression and zero or more logical expressions at one or more subsequent levels to said particular expression, said characteristic outputs representing outputs generated by a specified logical expression and zero or more logical expressions at one or more preceding levels to said specified logical expression;

    (c) storing in a memory a search data structure used to store a plurality of groups, each said group representing equivalent expressions having common group attributes, each said group including at least one logical expression, zero or more equivalent expressions associated therewith, and one or more plans, each of said plans implementing at least one expression associated with each said group;

    (d) for each said logical expression in said query tree, storing each said logical expression in a corresponding one of said groups in said search data structure associated with each said logical expression'"'"'s group attributes;

    (e) obtaining a plurality of rules for use in generating one or more equivalent expressions or one or more plans;

    (f) partitioning said query tree into one or more levels of subproblems, each subproblem including one or more of said logical expressions stored in said search data structure, a first level having one of said subproblems representing said root expression, each subproblem at each subsequent level representing one of said inputs to a corresponding logical expression at a preceding level, each subproblem associated with one of said groups in said search data structure;

    (g) determining at least one plan for each of said subproblems, said determining step further comprising the steps of;

    (1) selecting a set of one or more rules for application to one or more expressions of a particular one of said subproblems;

    (2) generating zero or more equivalent expressions from applying said set of rules to one or more expressions associated with said particular subproblem;

    (3) for each said generated equivalent expressions,(i) providing an associated set of group attributes for each said generated equivalent expression,(ii) using said group attributes and said generated equivalent expression to determine if a duplicate expression matching said generated equivalent expression is currently stored in said search data structure, and(iii) storing said generated equivalent expression in a group of said search data structure having equivalent group attributes when no duplicate expression as said generated equivalent expression exists in said search data structure; and

    (4) forming one or more plans from one or more expressions associated with said particular subproblem; and

    (h) generating a plan for said database query from said plans associated with each of said subproblems.

View all claims
  • 6 Assignments
Timeline View
Assignment View
    ×
    ×