Abstract:
A query optimizer for optimizing join queries in a relational database system by iterative application of dynamic programming (DP) to select optimal subgraph join execution plans. Unlike traditional DP optimization methods, bounds on search space time and space complexity can be established and adjusted by imposing a subgraph threshold. Each bounded subgraph is selected using a greedy heuristic (GH) hill-climbing procedure or other similarly useful technique to build a low-cost execution plan. The low-cost GH subgraph execution plan is then discarded in favor of an optimal DP subgraph execution plan selected by a dynamic programming optimizer for each subgraph identified by the bounded GH optimization process. The complexity bound may be dynamically tuned to improve execution plan quality responsive to changes in query complexity.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     This invention relates generally to relational database query optimizer systems and specifically to an iterative dynamic programming system for successive optimization of query plans after parsing into subgraphs by a greedy join heuristic. 
     2. Description of the Related Art 
     Query optimizers operate in relational database management systems to translate queries posed in a non-procedural language such as SQL into an efficiently executable plan. Reference is made to C. J. Date, An Introduction to Database Systems, Vol. 1, 4th Ed., &#34;Chapter 16: Query Optimization&#34;, p. 335 et seq., Addison-Wesley Publishing Co., Reading, Mass. (1986), for an overview of the optimization process known in the art. According to Date, the query optimization process has four stages. These are (a) recasting the user query into some internal representation, (b) convening to canonical form, (c) choosing prospective implementation procedures and generating executable plans, and (d) choosing the optimum (lowest cost) of such plans. 
     The &#34;Query Graph Model&#34; described by Pirahesh et al. (&#34;Extensible Rule-Based Query Rewrite Optimization in STARBURST&#34;, Proc. ACM-SIGMOD Intl. Conf. on Management of Data, San Diego, Calif., June 1992, pp. 39-48) is an example of a preferred internal representation of the user query known in the art, and the &#34;join graph&#34; is an example of a preferred canonical form. As used herein, a join graph denominates a user query representation having nodes connected by edges, wherein each node represents a relation and each edge represents a join predicate. The &#34;join&#34; operator is a powerful relational database operator that creates a new relation from the elements of two operands; the &#34;outer&#34; relation and the &#34;inner&#34; relation. The outer and inner relations can be represented as two nodes in a join graph connected by an edge representing the join predicate or condition imposed by the join. As is well-known in the relational database art, a &#34;relation&#34; denominates a database table having rows (&#34;tuples&#34;) and columns. A &#34;join predicate&#34; relates columns of two relations to be joined by specifying conditions on column values. Each column in a relation referenced by a join predicate is herein denominated a &#34;join column&#34;. The &#34;cardinality&#34; of a relation denominates the number of tuples embraced by the relation and the &#34;selectivity&#34; of a join predicate denominates the expected fraction of tuples for which the join column value in the relation satisfies the predicate. Accordingly, as is well-known in the art, query cardinality is the product of the cardinalities of every relation in the query times the product of the selectivity factors of the query predicates. 
     The art is replete with detailed descriptions of the join query. For instance, in U.S. Pat. No. 5,241,648, entirely incorporated herein by this reference, Cheng et at. disclose a hybrid technique for joining tables that selects a join execution plan from among the well-known &#34;nested-loop&#34; and &#34;sort-merge&#34; methods. In U.S. Pat. No. 5,043,872, entirely incorporated herein by this reference, Cheng et al. disclose a method for optimizing query execution that relies on measuring the degree of &#34;clustering&#34; (sortedness) in the stored relations. That is, Cheng et al. propose testing each join column to calculate the degree of clustering of the column values in their storage order to estimate the number of page accesses required for a partial index scan. These estimates are then used to calculate the &#34;cost&#34; of each proposed join execution plan, leading ultimately to an &#34;optimal&#34; plan. 
     For a lucid discussion of the &#34;join graph&#34;, reference is made to Kiyoshi Ono et al. (&#34;Measuring the Complexity of Join Enumeration in Query Optimization&#34;, Proc. of the 16th Intl. Conf. on Very Large Data Bases, Brisbane, Australia, pp. 314-325, 13-16 Aug. 1990). Ono et al report experimental results demonstrating that the complexity of query optimization is largely dependent upon the shape of the query graph, which indicates both the number and manner of relation interconnection by predicates. They further demonstrate that enumeration of the join sequences for a query is the dominant factor in both the time required to select an optimal query execution plan and the quality of the resulting plan. Ono et al. describe &#34;linear queries&#34; as a series of relation nodes each connected by predicate edges to no more than two other relation nodes. They also describe &#34;star&#34; queries as a group of relation nodes with a single central relation node connected by predicate edges to each of the other relation nodes. As described by Ono et al., any user query can be recast as a join graph made up of some combination of &#34;linear&#34; and &#34;star&#34; subgraphs. 
     Much effort in the query optimization art is devoted to improving on Date&#39;s third step of choosing prospective implementation procedures and generating executable plans. The query optimizer known in the relational database management system art translates nonprocedural queries into a procedural plan for execution, typically by generating many alternative plans, calculating the execution cost of each and choosing the plan having the lowest estimated cost. Because relational database management systems typically support only diadic (2-way) join operators as permutative operations, the query optimizer must choose the &#34;best&#34; sequence of two-way joins to achieve the N-way join embodied in a user query. A join graph representing such a series of two-way joins is generated during Date&#39;s second step as a &#34;canonical&#34; form of the query graph model (QGM). The practitioner may then either (a) exhaustively enumerate all possible &#34;feasible plans&#34; for join execution, using &#34;dynamic programming&#34;, or may (b) employ some &#34;heuristically limited&#34; search method to reduce the number of alternative plans in the search space considered by the optimizer. It is easily proven that dynamic programming never eliminates an optimal plan, because all possible plans are enumerated and evaluated. However, any &#34;heuristic&#34; search method known in the art presents some non-zero probability of excluding a superior execution plan without notice. There are usually many feasible plans for any given query and many practitioners use the exponential worst-case complexity argument to justify a&#39;priori search space truncation through heuristic search methods. That is, because dynamic programming search spaces grow as N|, practitioners using large DBMSs normally do not consider such exhaustive enumeration methods for search space generation. Herein, a &#34;search space&#34; denominates a set of executable query plans selected on the basis of some criteria related to primitive database operators. 
     As may be expected, the query optimization art is replete with &#34;heuristic&#34; search methods for limiting the time and space complexity of query optimization (which is different from query execution cost) by truncating the enumeration of feasible query execution plans. Dynamic programming (DP) is the time-honored method for optimizing join queries in relational database management systems and virtually all commercial optimizers rely on some abbreviated form of DP for this purpose. DP uses exhaustive enumeration with pruning to produce &#34;optimal&#34; execution plans without any measurable probability of missing the best of these plans. Reference is made to Selinger et al. (&#34;Access Path Selection in a Relational Database Management System&#34;, Proc. of the 1979 Assoc. of Comp. Mach. (ACM) SIGMOD Intl Conf. on Management of Data, Boston, Mass., June 1979, pp. 23-34) for a detailed description of the DP optimizer known in the art. Selinger et al. observe that, although the cardinality of the join of N relations is the same regardless of join order, the &#34;cost&#34; of joining in different orders may vary substantially. Accordingly, for a N-way join query, there are N| permutations of relation join orders embraced by the &#34;search space&#34; generated by DP. 
     This exponential time and space complexity of DP represents a significant weakness that makes DP impractical in some applications. For instance, an ad hoc join query with sixteen small relations may require more time for query &#34;optimization&#34; than for the actual execution of any one of the plans in the exponentially-large search space. For this reason, many practitioners employ heuristic techniques for limiting the number of feasible plans in the search space during query optimization. For instance, one heuristic operates to construct only joins in which a single relation is joined at each step with the results of previous joins, in a pipelined fashion. This generates plans that avoid so-called &#34;composite inners&#34; (often referred to as &#34;bushy trees&#34;) in which the inner join operand is a result of a join of several relations that must be materialized in memory or on disk. The pipelined heuristic saves the cost of this materialization but may (indeed, often will) exclude better plans for certain queries, as described by Ono et al. in the above-cited reference. 
     Another technique is the adaptive search space technique disclosed by Lohman et al. in U.S. Pat. No. 5,301,317, entirely incorporated herein by this reference. Lohman et al. describe an automated method for trading off estimated query optimization time against estimated query execution time when establishing the DP search space. They first select the least costly plan from a small search space defined by disabling all &#34;optional&#34; classes of plan alternatives. This first &#34;optimal&#34; execution plan is then evaluated to obtain an initial estimate of query execution time, which is then evaluated to determine whether the time needed for additional query optimization in a larger search space is warranted. 
     The significant disadvantage of any heuristic limitation of DP search spaces is the non-zero probability of unknowingly eliminating the best join execution plan from the search space. The tension between exhaustive enumeration (using DP) and heuristic limitation (HL) of a search space is a manifestation of the &#34;global optimization problem&#34; known in the mathematical arts. The global optimization problem is generally considered to be the problem of locating a global optimum in a large space having many local optimal. Each solution to a combinatorial optimization problem can be viewed as &#34;state&#34; in a &#34;state space&#34;. For query optimization, the state space is the search space wherein each state represents a complete ordered &#34;join sequence&#34; describing the feasible join execution plan for a query. Each state in the search space has a &#34;cost&#34; associated with it as defined by some &#34;cost function&#34;. A &#34;move&#34; is a perturbation applied to a solution to get another solution; that is, one &#34;moves&#34; from the state represented by a former solution to the state represented by a new solution. A &#34;move set&#34; is the set of moves available to proceed from one state to another, where each state in the search space is associated with a &#34;move set&#34;. A move is chosen from the move set according to a probability distribution specified as part of the move set. Two states are said to be &#34;adjacent&#34; states if one move suffices to go from one state to the other. The &#34;local minimum&#34; in the state space is a state such that its cost is lower than that associated with all adjacent states. There may be many such local minima. A &#34;global minimum&#34; is a state that has the lowest cost among all local minima in the state space. 
     The usual practical solution to the global optimization problem is to search through the space while indexing across several of the local optimal until such time as the search &#34;should&#34; be terminated according to some heuristic limitation (HL) criteria. Reference is made to, for instance, Arun Swami (&#34;Optimization of Large Join Queries: Combining Heuristics and Combinatorial Techniques&#34;, Proc. of 1989 ACM-SIGMOD Intl Conf. on Management of Data, Portland, Oreg., June, 1989, pp. 367-376) for a discussion of the use of heuristics in optimizing queries with a large number of joins. Swami describes the &#34;augmentation&#34; heuristic and the &#34;local improvement&#34; heuristic as well as the heuristic proposed by Krishnamurthy et at. and compares these with the iterative improvement (II) and the simulated annealing (SA) combinatorial optimization techniques known in the global optimization art. 
     Some HL optimization procedures rely on randomization to reduce search space complexity. Although these randomized HL processes offer useful alternatives to DP, none are easily incorporated into DP optimizers because they do not enumerate joins in the same bottom-up manner as does DP. For instance, Y. Ioannidis, et al. (&#34;Randomized Algorithms for Optimizing Large Join Queries&#34;, Proc. of the 1990 ACM-SIGMOD Intl. Conf. on Management of Data, Atlantic City, N.J., 23-25 May 1990, pp. 312-321) discuss the SA and II randomized processes for query optimization. Ioannidis et al. conclude that SA identifies a lower cost access plan than II because the shape of the cost function over the solution space associated with such queries resembles a &#34;cup&#34; with relatively small variations at the bottom, which minimizes the opportunity for &#34;false&#34; optimal. They also describe a &#34;Two Phase Optimization&#34; process that combines SA and II to some advantage. 
     Simulated annealing (SA) is a member of the class of probabilistic &#34;hill-climbing&#34; algorithms known in the general global optimization art as risky. That is, because the hill-climbing algorithms are &#34;greedy&#34;, the procedures inevitably stop at the first &#34;local&#34; optimum found in the search space, without any further struggle toward the &#34;global&#34; optimum. The SA procedure can be combined with heuristic &#34;enhancements&#34; to help overcome the greediness of the algorithm, as discussed by Ioannidis, et al. in a second paper (&#34;Query Optimization by Simulated Annealing&#34;, Proc. of the 1987 ACM-SIGMOD Conf. on Management of Data, San Francisco, Calif., 27-29 May 1987, pp. 9-22), but some risk remains in any SA process. 
     The Sgd process described by Chen et al. (&#34;Scheduling and Processor Allocation for Parallel Execution of Multi-Join Queries&#34;, Eighth Intl. Conf. on Data Engrg, Feb. 3-7, 1992, p. 60) is a simple &#34;greedy heuristic&#34; that is widely used in such systems as the Data Base 2 (DB2/6000) Data Base Management System sold by the International Business Machines Corporation. The Sgd procedure starts at a state and randomly selects adjacent states to test the change in &#34;cost&#34; incurred by moving from the initial state to each new adjacent state. This iterative process continues until a &#34;local minimum&#34; state is identified. 
     Some practitioners attempt to reduce search space complexity by tinkering with the cost formula for the several states within the search space. For instance, A. Shibamiya et al. &#34;DB2 Cost Formula&#34;, IBM Technical Disclosure Bulletin, Vol. 34, No. 12, pp. 389-394, May, 1992) discuss the cost formula used in the DB2 query optimizer, which attempts to dynamically select the most efficient access path based on selected statistics available at execution time. Similarly, D. Cornell et al. (&#34;Integrated Buffer Management and Query Optimization Strategy for Relational Databases&#34;, IBM Technical Disclosure Bulletin, Vol. 32, No. 12, pp. 253-257, May, 1990) describe an &#34;objective function&#34; that is similar to the cost function but is improved by summing over all query types weighted by query frequencies. 
     Others have proposed heuristics based on relation constraints. For instance, E. R. Omiecinski (&#34;Heuristics for Join Processing Using Nonclustered Indexes&#34;, IEEE Trans. on Software Engineering, Vol. 15, No. 1, pp. 18-25, January, 1989) describes a useful heuristic for minimizing the number of page accesses needed to compute a join when only non-clustered access paths are available. Lee et al. (&#34;Semantic Query Reformulation in Deductive Databases&#34;, IEEE Proc. of the 7th Intl. Conf. on Data Engr., Koby, Japan, 8-12 Apr. 1991, pp. 232-239) describe a method for identifying relevant integrity constraints for queries involving joins or unions of base relations with defined relations by use of join graphs. In U.S. Pat. No. 5,067,166, Ito describes a pattern recognition method and apparatus using dynamic programming to match an input label sequence to a set of candidate templates. Ito does not consider the application of DP to query optimization, but does provide a lucid theoretical description of dynamic programming. 
     Many practitioners have proposed query optimization techniques adapted to special database applications such as &#34;cyclic&#34; (recursive) queries and &#34;distributed&#34; databases. For instance, application of the &#34;fix-point&#34; operator to recursive query execution is described by Shan et al. (World Intellectual Property Organization Publication No. WO 92/15066) and Kabler et al. (&#34;Performance Evaluation of Algorithms for Transitive Closure&#34;, Information Systems, Vol. 17, No. 5, pp. 415-441, September 1992). In particular, Kabler et al. discuss the general execution problem of computing the transitive closure of a directed graph in a disk-based environment but neither consider nor suggest application of their theoretical strategies to the query optimization art. Chi et al. &#34;Recursive Query Answering with Non-Horn Clauses&#34;, Proc. of the 9th Intl. Conf. on Automated Deduction, Argonne, Ill., 23-26 May 1988, pp. 294-313) describe a method for answering recursive queries under the Generalized Closed World Assumption (GCWA) in a database having positive non-Horn ground clauses. In U.S. Pat. No. 5,345,585, entirely incorporated herein by this reference, Iyer et al. describe a heuristic for optimizing cyclic (recursive) join queries that combines randomizing and local improvements with a previously known polynomial time query optimization procedure. They use both nested-loop and merge join methods to optimize cyclic joins in time O(N 4 ). 
     Other practitioners consider query optimization in distributed databases, employing the &#34;semi-join&#34; operator known in the art. For instance, in U.S. Pat. No. 4,769,772, P. Dwyer describes an automated query optimization method using both global and parallel local optimization for Materialization and Access Planning (MAP) in a distributed database system. Dwyer chooses to optimize locally if such is more efficient than optimizing over the distributed system. S. Pramanik et al. (&#34;Optimizing Join Queries in Distributed Databases&#34;, IEEE Trans. on Software Engr., Vol. 14, No. 9, pp. 1319-1326, September 1988) consider query optimization using semi-join operators and observe that the class of user queries represented by &#34;acyclic&#34; (nonrecursive) join trees can be executed with a sequence of semi-joins. The acyclic class of join graphs is known to include all join graphs wherein no predicate edge closes an uninterrupted circuit formed by an edge plurality. Chen et al. (&#34;Properties of Optimal Semi-Join Programs for Distributed Query Processing&#34;, Proc. of the IEEE Comp. Soc. 7th Intl. Comp. Software and Appls. Conf., Chicago, Ill., 7-11 Nov. 1983, pp. 476-483) discuss the properties of optimal semi-join programs for processing distributed query graphs and introduce the &#34;execution graph&#34; to represent semi-join programs. Chen et al. show how to develop an efficient procedure for deriving optimal semi-join programs by exhaustive search to overcome the sub-optimal selection problem known for distributed query optimization. In a second paper, Chen et al. (&#34;Using Join Operations as Reducers in Distributed Query Processing&#34;, Proc. 2nd Intl. Sym. on Databases in Parallel and Distributed Systems, Dublin, Ireland, 2-4 Jul. 1990, pp. 116-123) describe a judicious application of join operations to reduce complexity in semi-join graphs for distributed queries according to an efficient heuristic limitation procedure. Cornell et at. (&#34;Integrated Site Assignment for Relations and Join Operations in Distributed Transaction Processing&#34;, IBM Technical Disclosure Bulletin, Vol. 32, No. 4A, pp. 306-314, September 1989) describe a technique for minimizing the inter-site message traffic needed to execute join queries by first decomposing queries into relational steps and then making integrated site assignments based on linear integer programming techniques. 
     There remains a clearly-felt need in the art for improved query optimization techniques in large relational database management systems. The primary objective for any query optimizer system is to ensure that the solution space of feasible plans contains the most efficient plans without making the space too large for practical generation and search. The DP optimizer produces exponentially complex solution spaces as the price for ensuring identification of the global optimum execution plan. None of the many heuristic limitation (HL) optimizers known in the art can limit solution space complexity without unpredictably eliminating optimal solutions and thereby losing any assurance that the limited space embraces the globally optimum solution. 
     There is accordingly a need in the art for a dynamic programming (DP) optimization technique with bounded solution space complexity. The related unresolved problems and deficiencies are clearly felt in the art and are solved by this invention in the manner described below. 
     SUMMARY OF THE INVENTION 
     The system of this invention is a new &#34;iterative&#34; dynamic programming (IDP) technique for generating execution plan solution spaces of bounded complexity. The IDP system of this invention iteratively calls the dynamic programming (DP) process for query graph subsets of T L  or fewer relations, where T L  represents a predetermined size limit that may be arbitrarily selected to limit the solution space complexity. The join graph is divided into subgraphs of no more than T L  relation nodes by a &#34;greedy heuristic&#34; procedure or other similarly useful process before subgraph optimization through exhaustive enumeration of execution plans by DP. 
     It is an object of this invention to limit optimizer search space complexity without unpredictably eliminating the most efficient query execution plans therefrom. It is an advantage of the method of this invention that the final execution plan includes a known global optimum for each of the query subgraphs generated by the greedy heuristic. It is a feature of the method of this invention that the (perhaps suboptimal) execution plans generated by the greedy heuristic procedure do not appear in the final optimal query execution plan. 
     It is another object of this invention to provide an improved query optimization technique that can be immediately applied to any existing database management system that uses dynamic programming (DP). It is an advantage of the system of this invention that any existing DP query optimizer can be quickly and efficiently modified to incorporate the method of this invention. 
     It is yet another object of the method of this invention to reduce thr query optimization cost for large join queries without incurring an unanticipated risk of unnecessary execution costs. It is an advantage of the IDP system of this invention that acyclic join queries can be optimized on average to within a few percent of the DP plan cost at a small fraction of the DP optimization cost. It is a feature of this invention that both the space complexity and the risk of suboptimal solutions are precisely controlled by a threshold parameter T L . 
     The foregoing, together with other objects, features and advantages of this invention, can be better appreciated with reference to the following specification, claims and the accompanying drawing. 
    
    
     BRIEF DESCRIPTION OF THE DRAWING 
     For a more complete understanding of this invention, reference is now made to the following detailed description of the embodiments as illustrated in the accompanying drawing, wherein: 
     FIG. 1 is functional block diagram of a flow chart showing a preferred method of this invention; 
     FIGS. 2A-2K illustrate the optimization of an exemplary acyclic query graph according to the method of this invention; 
     FIG. 3 is a functional block diagram of a computer system suitable for embodiment of the IDP query optimizer of this invention; 
     FIG. 4 is a functional block diagram showing in more detail the memory space of the computer system from FIG. 3; and 
     FIG. 5 is an exemplary computer program product incorporating means for directing a computer system to perform the method of this invention. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     FIG. 1 provides a flowchart exemplifying a preferred embodiment of the IDP query optimization process of this invention. FIG. 1 may be understood with reference to the following description and with reference to Table 1, which provides a pseudocode listing of the process of this invention. 
     
                                           TABLE 1__________________________________________________________________________IDP Pseudocode Embodiment__________________________________________________________________________input join graph G and size limit T.sub.Lwhile |G| &gt; 1 do                      //stop when no more relations to joinMinCost = ∞          //use min cost heuristicfor x, y in G connected by an edge do                      //examine all unjoined connected pairsJoin=mincost(plan x!×plan y!, plan y!×plan x!)                      //try both join ordersif Join.cost &lt; MinCost then                      //remember minimum cost join   NextJoin = Join   r = min (x,y)   S = max (x,y)   MinCost = Join.costendifendforif |relations r! ∪ relations s!| &gt; T.sub.L                      //has the size limit T.sub.L been exceeded?if |relations r!| &gt; |relations s!|then                       //call DP on the larger subgrapht = relset = sendifplan t! = DP(relations t!) //defer join and call DP for planrelations t! = {(relations t!)}                      //treat relations t! as compound elementelse                       //keep going with greedy heuristicplan r! = NextJoin         //update GH plan associated with rrelations r! = relations r! ∪ relations s!                    //collapse s into rrelations s! = 0endifendwhileoutput DP(relations 1!)    //call DP one last time__________________________________________________________________________ 
    
     In FIG. 1, an N-way join query is first converted to a Query Graph Model (QGM) at step 10. This procedure is well-known in the art and produces a canonical QGM herein denominated the &#34;join graph G&#34;. The process of this invention also requires the input of the predetermined limit, herein denominated the &#34;enumeration threshold T L  &#34;, shown at step 24 et seq. Enumeration threshold T L  represents the maximum number of relations in any subgraph G L  referred to the dynamic programming (DP) optimization process and operates to bound the complexity of the DP search space used in optimizing graph G, as described below. In Table 1, the term &#34;relations x!&#34; denominates the base relation or relation subgraph corresponding to relation node x and the term &#34;plan x!&#34; denominates the query execution plan selected by GH or DP for node x. Although not shown, the process is initialized with relations x!={x} and plan x!=ACCESS(x). In FIG. 1, the notation for relations x!is &#34;J(x)&#34;, which is herein denominated the &#34;node joinder number&#34; J x  for node R x  and represents the number of nodes in the subgraph G x  associated with node R x . 
     In FIG. 1, a &#34;mincost&#34; parameter is first set as high as possible at step 12. The inner loop then starts at step 14, where a first connected node pair (R x , R y ) is tested for execution cost in both directions (i.e., joining R x  to R y  with predicate E xy  and joining R y  to R x  with predicate E yx ). Step 14 selects the optimal two-way join plan for two relations from the search space having two plans differing only in the join order. The cost of the optimal join order for connected node pair (R x , R y ) is then tested against mincost at step 16 and, if the cost is not less than mincost, the procedure returns to step 14 to select another connected node pair for evaluation. If step 16 determines that the new two-way join plan has an execution cost that is less than the mincost saved from the previous optimal two-way plan, then step 18 resets some parameters to save the two-way join plan as the new &#34;nextJoin&#34; (the new optimal two-way join plan) and tests for more untested connected node pairs at step 20. 
     If step 20 shows more connected node pairs await testing, step 22 selects another such connected pair (arbitrarily) and returns to step 14 to evaluate the next pair. If no untested connected node pairs remain to be evaluated, step 24 tests the two-way join complexity by adding the node joinder numbers J r  +J s  for the connected node pair (R r , R s ) found to have the lowest cost of all such pairs in graph G. This sum is compared to the enumeration threshold T L  at step 24 and, if J r  +J s  &lt;T L , then step 26 merges the connected node pair (R r ,R s ) into a single node R r  having a new node joinder number J r  =J r  +J s  and node R s  is eliminated from the join query graph G. The procedure returns to step 12 (after testing for more node pairs in step 34) to re-examine every one of the connected node pairs in the join query graph modified by the merger of nodes r and s. 
     The process shown in steps 12 through 26 continues until step 24 finds that the proposed two-way join exceeds the complexity bound imposed by enumeration threshold T L . When this occurs, the procedure branches to step 28 to determine the larger of the two subgraphs G r  and G s  represented by modes (r,s). The larger subgraph G t  is selected for DP optimization in step 30. 
     Step 30 makes a call to the dynamic programming (DP) optimizer process for optimization of the subgraph G t  that embraces the J t  relations represented by the larger of the two subgraphs G r  and C s . After step 30 exhaustively enumerates all joint execution plans and selects the optimal plan P t  for subgraph G t , the node joinder number J t  is reset to unity to indicate that node R t  now represents execution plan P t  and that the join subgraph G t  will not be re-optimized again in this process. After resetting J t  at step 32, join graph G is reviewed to see if additional connected node pairs exist at step 34. If another connected node pair (R x ,R y ) is found in graph G, the procedure returns to step 12 substantially as shown in FIG. 1. If no more connected node pairs exist; that is, if the earlier procedure has finally reduced join graph G to a single node, then step 36 makes a final call to the DP optimizer to optimize the relation join plan at the final node, thereby producing the execution plan P for the entire join graph G. 
     Referring to Table 1 and FIG. 1, it can be appreciated that the main loop (steps 14 through 22) is nearly identical to the greedy Sgd heuristic discussed above in connection with the recited 1992 Chen et at. reference. The IDP method of this invention uses a greedy heuristic (GH) such as the II process to divide the join graph G into subgraphs having T L  or fewer relations. The GH optimization is first performed to generate one or more subgraphs, each of which is allowed to build up a GH query plan join-by-join. After adding to the GH plan the join for a connected node pair, the two nodes in the pair are collapsed into a single node in join graph G. Whenever the GH optimizer discovers that the next join must exceed enumeration threshold T L , the join is deferred and the DP optimizer is called to optimize the larger of the two subgraphs embraced by the attempted join. This process continues until the GH process adds the last join to a GH plan, at which point DP is called once more to optimize the remaining subgraph. 
     Advantageously, the GH join plans generated by the GH process never appear in the final output plan P. All join plans in the final output plan P are DP plans generated by dynamic programming. While the final output plan P cannot be assured of optimality, the plan for each of the several subgraphs is assuredly optimal and the final plan P is a combination of these optimal subgraph plans. This invention uses a GH process to intelligently divide the join graph G into subgraphs of T L  or fewer relations. Unbounded DP optimizers can be shown to have time and space complexity of O(3 N ) and O(2 N ), respectively, where N is the number of relations to be joined in graph G (according to the above-cited Ono et al. reference). Consequently, the time and space complexity of the bounded Iterative Dynamic Programming (IDP) procedure of this invention can be shown to be ##EQU1## respectively. This invention for the first time allows the complexity to be &#34;tuned&#34; by changing the T L  threshold value. 
     An example is now provided to assist in appreciating the method of this invention. Referring to FIG. 2A, a 6-way join graph G is shown as joining seven relations {R 1 , R 2 , . . . R 7  } by means of six predicates {E 17 , E 12  . . . , E 56  }. Essentially, join graph G in FIG. 2A depicts a six-way join query by depicting each relation as a relation node R i  and by depicting each two-way join as a predicate edge E ij  connecting two nodes to form a connected node pair (R i , R j ). This nomenclature is familiar to practitioners in the relational database query optimization art and is used consistently throughout this disclosure. Initially, each relation node in FIG. 2A is assigned a node joinder number J i  =1 (not shown), thereby representing that each relation node embraces a subgraph consisting of a single &#34;base&#34; relation. The enumeration threshold T L  is set to 3 for this example. 
     FIG. 2B represents the join graph G after the first completion of GH step 26 (FIG. 1). In the example, the GH optimizer has selected the connected node pair (R 2 , R 3 ) as having the optimal join cost of all possible two-way joins in graph G. This connected node pair is collapsed according to this invention in FIG. 2B into the lower-numbered relation node R 4  having a node joinder number J 4  =2. 
     In FIG. 2C, the GH optimizer has selected the connected node pair (R 2 , R 3 ) the lowest two-way join cost of all possible 2-way joins in the graph G of FIG. 2B. Note that the IDP process of this invention does not restrict the GH optimizer to a &#34;pipelined&#34; join with the previously joined subgraph G 4  at collapsed node R 4 , which is an important feature of the method of this invention. After the connected pair (R 2 , R 3 ) is collapsed according to this invention into node R 2  having the node joinder number J 2  =2, the GH optimizer re-evaluates the five-node join graph in FIG. 2C and selects the connected node pair (R 6 , R 4 ) as having the optimal join cost (FIG. 2D). Collapsing the connected node pair (R 6 , R 4 ) into node R 4  increases the node joinder number J 4  to 3 because of the earlier node pair collapse. J 4  =3 does not exceed the enumeration threshold T L  =3 for this example so the GH optimizer next collapses the connected pair (R 6 , R 4 ) into a subgraph G 4  at relation node R 4  of FIG. 2D. 
     At this point, the GH optimizer selects the node pair (R 2 , R 4 ) as having the optimal join cost. However, because J 2  +J 4  =5&gt;T L  =3, the GH optimizer halts and calls the DP optimizer to create a globally optimal execution plan for the (larger) subgraph G 4  embraced by relation node R 4 . As seen in FIG. 2E, the DP optimizer creates a plan P 4  for joining subgraph G 4  embracing nodes R 4 , R 5 , and R 6 . After creating plan P 4 , the node joinder number J 4  is reset to 1 and the GH optimizer process returns to the four-node graph G in FIG. 2E. 
     In FIG. 2F, perhaps because of the replacement of node R 4  with plan P 4 , the GH optimizer next selects the connected pair (R 1 , R 7 ) instead of (R 2 , P 4 ). This pair is collapsed into relation node R 1  and J 1  is set to numeral 2. Subsequently, the GH optimizer attempts to join the connected node pair (R 2 , R 1 ) but is halted because J 2  +J 1  =4&gt;T L  =3. Although the larger of the two join subgraphs G 2  and G 1  should be selected, one is arbitrarily selected because J 1  =J 2  =2. As seen in FIG. 2G the DP optimizer is called to optimize the subgraph G 2  represented by node R 2  and the globally optimum plan P 2  is selected, with J 2  reset to 1. In FIG. 2H, the connected pair (P 2 , R 1 ) is finally collapsed by the GH process into relation node R 1  having a node joinder number J 1  =3=J 2  +J 1 . 
     Once again, the GH optimizer halts upon attempting to join the connected node pair (P 4 , R 1 ) because J 4  +J 1  =4&gt;T L  =3. FIG. 2I shows the result of DP optimization of the larger subgraph G 1  to produce optimal execution plan P 1 , where J 1  is reset to 1. In FIG. 2J, the GH process collapses the last connected node pair (P 4 , P 1 ) into node R 1  having a node joinder number J 1  =2. 
     FIG. 2K illustrates the final step 36 (FIG. 1) where the DP optimizer is called to select an optimal execution plan for subgraph G 1 . Importantly, this final execution plan P 1  represents the &#34;global&#34; optimum execution plan for joining the subgraphs G 4  and G 1 . From the example shown in FIG. 2K, it can be appreciated that the Iterative Dynamic Programming method of this invention reduces the complexity of query optimization in a selectable fashion while minimizing the possibility of unknowingly missing optimal execution plans. 
     FIG. 3 provides a functional block diagram exemplifying a data processing system suitable for implementation of the system of this invention. In FIG. 3, a data processor 38 is shown coupled to a primary bus 40 and a memory space 42. Bus 40 is also coupled to a direct access storage device (DASD) external store 44 and a magnetic tape external store 46, both suitable for the permanent storage of database relations. A user terminal 48 suitable for query input is also shown coupled to bus 40. 
     In FIG. 4, memory space 42 is shown in greater detail. The IDP system of this invention may be embodied as a collection of program and data processes in computer memory substantially as shown in FIG. 4, wherein the user database query is first stored as an input query 50. Input query 50 is processed by a Query Graph Model (QGM) generator process 52 to produce a QGM 54, herein denominated the join graph G. 
     The iterative dynamic programming (IDP) optimizer of this invention includes the IDP control process 56, which accepts join graph G from QGM 54 and calls either a greedy heuristic (GH) optimizer process 58 or the dynamic programming (DP) optimizer process 60, as appropriate. After completion of the process discussed above in connection with Table 1 and FIG. 1, IDP control process 56 produces an optimal query execution plan 62, herein denominated the optimal plan P, thereby completing the IDP query optimization process of this invention. 
     The inventors have conducted experiments to obtain some measure of the actual improvement in query optimization efficiency realized over the DP system by the IDP system of this invention. In each experiment, 16-way join queries were optimized by DP and IDP optimizers and resulting plans were compared on the basis of estimated cost using a simple sort-merge-join cost model. No restrictions were placed on the shape of the execution trees and arbitrarily bushy trees were permitted. 
     In conducting the 16-way join experiments, the inventors used the key parameter values shown in Table 2. The Table 2 parameters were selected after some experimentation with different values showed that results were reasonably consistent without regard to actual parameter values. 
     
                       TABLE 2______________________________________Key Parameter SettingsDescription            Default______________________________________processor speed        40 MIPScost to compare 2 records                  200 instructionsrecord size            200 bytesI/O block size         256 KBdisk bandwidth         3 MB/secrelations in each join N = 16size limit T.sub.L for IDP                  T.sub.L = 10number of experiments  100______________________________________ 
    
     Join graphs were generated using the procedure described by Hong et al. (&#34;Optimization of Parallel Query Execution Plan in XPRS&#34;, Distributed and Parallel Databases, vol. 1, no. 1, pp. 9-32, January 1993). To generate a random join of k relations, Hong et al. first randomly chose k relations. Then they started by moving the first relation to a chosen list, leaving the rest in an unchosen list. They randomly picked a relation in the unchosen list, joined it with a randomly picked relation from the chosen list on two randomly chosen attributes and moved it from the unchosen list to the chosen list. They repeated this operation until the unchosen list became empty; thereby generating a random join on k relations. This procedure generates only &#34;acyclic&#34; graphs. The inventors selected relation cardinalities and join selectivities to create a large variance in the cost of different queries. 
     Four relation sizes were used; small, medium, large and very large. Each had an equal probability of being chosen. The cardinalities of small, medium, large and very large relations were uniformly distributed over the intervals (1K, 2K,), (10K, 20K), (100K, 200K), and (1,000K, 2,000K) tuples, respectively. 
     The results of the inventor experiments are shown in Table 3, wherein the first column shows the cost of the plans generated by the IDP method of this invention relative to the DP method known in the art, averaged over 100 trials. That is, by denominating DP i  and IDP i  to be the cost of the plan generated by DP and IDP for the i th  query, respectively, then the first column in Table 3 is the mean ±standard deviation of the ratio IDP i  /DP i . As may be appreciated with reference to Table 3, the IDP of this invention is (on average) capable of optimizing large join queries to within 6% of DP effectiveness in 0.5% of the time and in 9% of the space necessary for DP optimization. Not surprisingly, the number of joins enumerated was also significantly less for IDP. 
     
                       TABLE 3______________________________________Summary of Results  Relative  Avg Joins   Avg Space                                AvgProcess  Plan Cost Enumerated  Consumption                                Opt Time______________________________________DP     1.00 ± 0.00            28,156      340KB   425 secIDP    1.06 ± 0.02             1,383       30KB    2 sec______________________________________ 
    
     Advantageously, the IDP optimization system of this invention can be built on top of an existing DP process so that existing DP optimizers, such as the optimizer used in the DB2/6000 DBMS sold by the International Business Machines Corporation, can be easily extended to incorporate the IDP procedure of this invention. In particular, existing machinery for handling order requirements, multiple joins, access methods, and the like, can be used without modification. More advantageously, the IDP optimizer of this invention can be dynamically tuned to any desired optimization level, which is not possible with any other heuristic limitation optimizer process known in the art. Finally, the IDP process of this invention is much more robust than the heuristic limitation processes known in the art because the DP optimizer exhaustively enumerates plans for each of the subgraphs making up the join query. 
     While this invention is primarily described as a process, it can be appreciated by a person of ordinary skill in the art that an apparatus, such as the data processing system discussed above in connection with FIGS. 3-4, can be configured to facilitate the practice of the process of this invention. Such a processor may include appropriate program means for executing the process of this invention such as described above in connection with FIG. 4. Also, an article of manufacture, such as the pre-recorded floppy disk 64 shown in FIG. 5 or other similar computer programming product intended for use with a data processing system, may include a storage medium and program means recorded thereon for directing the data processing system to facilitate the practice of the process of this invention. For example, in FIG. 5, disk 64 may include stored program objects exemplified by program object 66 for directing a data processing system to invoke a GH optimizer, program object 68 for directing a data processing system to invoke a DP optimizer, program object 70 for directing a data processing system to iterate between GH and DP optimizers substantially as described above in connection with FIG. 1, and a program object 72 for directing a data processing system to select a final optimal execution plan for a join query. It should be readily appreciated that such computer program products and like articles of manufacture also fall within the spirit and scope of this invention. 
     Clearly, other embodiments and modifications of this invention may occur readily to those of ordinary skill in the art in view of these teachings. Therefore, this invention is to be limited only by the following claims, which include all such embodiments and modifications when viewed in conjunction with the above specification and accompanying drawing.