USPatent applicationPatented

Performing a multiple table join operating based on generated predicates from materialized results

Granted 19 May 2009 · 3 office actions

Life of the application

12 dated events
⤢ drag to zoom2006200820102012201420162018202020222024ProsecutionOwnershipTerm & fees
ProsecutionOwnershipTerm & feeshover for detail · click to open

Abstract

An improved mechanism for processing a multiple table query includes: determining if any tables in the query require materialization; for each table in the query that requires materialization, deriving at least one join predicate on a join column; determining if any tables earlier in a join sequence for the query has same join predicates; and applying the at least one derived join predicate to an earlier table in the join sequence, if there is at least one table earlier in the join sequence that has the same join predicate. This significantly reduces the number of rows that are joined before arriving at the final result.

Description

6 parts
›FIELD OF THE INVENTION

The present invention relates to multiple table queries, and more particularly to the filtering of the result of multiple table queries.

›BACKGROUND OF THE INVENTION

Queries involving the joining of multiple tables in a database system are known in the art. For example, if a query includes a WHERE clause predicate and filtering occurs at more than one table, more rows than necessary may be joined between two or more tables before the filter is applied. The WHERE clause specifies an intermediate result table that includes those rows of a table for which the search condition is true. This is inefficient.

For example, assume a 10 table join. If each table has predicates that perform some level of filtering, then the first table may return 100,000 rows (after filtering is applied to this table), the second table filters out 20%, the third a further 20%, etc. If each table (after the first) provide 20% filtering, then the final result is approximately 13,000 rows for a 10 table join. Therefore, approximately 87,000 unnecessary rows are joined between tables 2 and 3, 67,000 between tables 3 and 4, etc.

Accordingly, there exists a need for an improved method for processing multiple table queries. The improved method should derive predicates based on a join relationship between tables and apply these derived predicates to tables earlier in the join sequence. The present invention addresses such a need.

›SUMMARY OF THE INVENTION

An improved method for processing a multiple table query includes: determining if any tables in the query require materialization; for each table in the query that requires materialization, deriving at least one join predicate on a join column; determining if any tables earlier in a join sequence for the query has same join predicates; and applying the at least one derived join predicate to an earlier table in the join sequence, if there is at least one table earlier in the join sequence that has the same join predicate. This significantly reduces the number of rows that are joined before arriving at the final result.

›BRIEF DESCRIPTION OF THE FIGURES

FIG. 1 is a flowchart illustrating an embodiment of a method for processing a multiple table query in accordance with the present invention.

FIG. 2 illustrates a first example of the method for processing a multiple table query in accordance with the present invention.

FIG. 3 illustrates a second example of the method for processing a multiple table query in accordance with the present invention.

›DETAILED DESCRIPTION · 1 of 2

The present invention provides an improved method for processing multiple table queries. The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. Various modifications to the preferred embodiment will be readily apparent to those skilled in the art and the generic principles herein may be applied to other embodiments. Thus, the present invention is not intended to be limited to the embodiment shown but is to be accorded the widest scope consistent with the principles and features described herein.

To more particularly describe the features of the present invention, please refer to FIGS. 1 through 3 in conjunction with the discussion below.

FIG. 1 is a flowchart illustrating an embodiment of a method for processing a multiple table query in accordance with the present invention. First, for each table, it is determined whether materialization is required, via step 101 . For any tables that are materialization candidates, via step 102 , the tables are accessed, and join predicates are derived on the join columns, via step 103 . Next, if there are tables earlier in the join sequence with the same join predicates, via step 104 , then the derived predicates are applied to an earlier table in the join sequence, via step 105 .

In this embodiment, the derived predicate is either of the type IN or BETWEEN, depending on the number of values in the result and the expected filtering. The IN predicate compares a value with a collection of values. The BETWEEN predicate compares a value with a range of values. The predicates are derived on the join predicates based upon the result after filtering to be applied to tables earlier in the join sequence. These predicates are derived on the join columns as they can only be applied to other tables where the predicates can be transitively closed through the join predicates. These predicates are then available as index matching, screening, or page range screening.

Derived predicates should be available as regular indexable (matching or screening) predicates similar to any other transitively closed predicate. This can provide a significant performance improvement if these filtering predicates can limit the data access on an earlier table in the I/Os, in addition to the reduction in rows that are joined from application of filtering earlier in the join process.

In this embodiment, an IN and/or a BETWEEN predicate is derived during runtime. Since the estimated size of the materialized result cannot be relied upon before the bind or prepare process because the actual number of rows in the materialized result cannot be guaranteed until runtime, the choice to generate a BETWEEN or IN predicate is a runtime decision. If the number of elements in the materialized result is small then generally an IN list that includes all elements would be more suitable. If the number of elements is large, then the low and high values should be selected from the materialized result to build the BETWEEN predicate.

For example, if the materialized result contained 2 values, 3 and 999, then it would be more beneficial to generate COL IN (3,999) rather than BETWEEN 3 AND 999. If the materialized result contains a larger number of values, such as 100, then the BETWEEN will generally become more efficient.

If the materialized result is a single value, then COL IN (3) OR COL BETWEEN 3 AND 3 are equivalent. A result of zero rows would trigger a termination of the query if it was guaranteed that the final result would be zero. This would be the case if access to the materialized result was joined by an inner join, where the column that is not common to all the tables being joined is dropped from the resultant table.

Optionally, a materialized result set can utilize one of the existing indexing technologies, such as sparse index on workfiles or in-memory index, to create an indexable result set where an index did not previously exist on the base table to support the join predicates. This makes it attractive to materialize tables where materialization was not previously mandatory, but by doing so provides a smaller result set to join to with a sparse index or as an in-memory index.

Although it is desirable to apply the derived predicates to the earliest possible table in the join sequence, other factors may limit this: if many tables provide strong filtering, then only one can be first in the table join sequence; sort avoidance may be the preference if a sort can be avoided by a certain join sequence; join predicates or indexing may dictate a join sequence that makes best use of join predicates but not filtering; and outer joins dictate the table join sequence.

FIG. 2 illustrates a first example of the method for processing a multiple table query in accordance with the present invention. In this example, there are three tables to be joined, T 1 , T 2 , and T 3 . With a join sequence of T 1 -T 2 -T 3 , filtering is applied to T 1 and T 3 . T 3 is determined to require materialization due to the GROUP BY clause, via steps 101 - 102 . A GROUP BY clause specifies an intermediate result table that contains a grouping of rows of the result of the previous clause of the subselect. Here, T 3 is accessed first, via step 103 , with the result stored in a workfile in preparation for the join of T 1 and T 2 . Thus, the join becomes T 1 -T 2 -WF (workfile from T 3 materialization).

Assume that T 1 .C 1 =? qualifies 5,000 rows, and the result of T 3 (after C 1 =? and GROUP BY) is 1,000 rows ranging from 555-3,200 (with maximum range of 1-9,999). Thus the join of T 1 to T 2 would be 5,000 rows. The T 1 /T 2 composite of 5,000 rows would then be joined with T 3 , with only 500 rows intersecting with T 3 result of 1000 rows.

Using the method in accordance with the present invention, in the process of materializing and sorting the result of T 3 , the high and low key of C 2 is determined to be 555 to 3220. At runtime, the predicate T 2 .C 2 BETWEEN 555 AND 3220 can be derived, via step 103 , after the materialization of T 3 , and then applied to T 2 , via steps 104 - 105 . The 5,000 T 1 rows will be joined to T 2 , but a subset of T 2 rows will qualify after the application of the BETWEEN predicate. Assuming T 2 and T 3 form a parent/child relationship, 500 rows will quality on T 2 after the derived predicate is applied. If this predicate is an index matching predicate, then 4500 less index and data rows will be accessed from T 2 . Regardless of when the predicate is applied to T 2 , 4500 less rows will be joined to T 3 .

›DETAILED DESCRIPTION · 2 of 2

FIG. 3 illustrates a second example of the method for processing a multiple table query in accordance with the present invention. This example includes star join queries, which can have filtering come from many dimension and/or snowflake tables. Star join queries are known in the art. Here, the filtering comes from dimension tables DP, D 5 and D 6 , and also snowflake tables D 1 /X 2 /Z 1 and D 3 /X 1 . Not all filtering can be applied before the fact table, F, because of index availability and also to minimize the Cartesian product size.

Assume, based upon index availability, the table join sequence is D 5 -D 6 -F-SF 1 (D 1 /X 2 /Z 1 )-SF 2 (D 3 /X 1 )-DP, where SF 1 and SF 2 are materialized snowflakes. While materializing and sorting these snowflakes, the key ranges on the join predicates can be generated or derived, via steps 101 - 103 and applied against the fact table, via steps 104 - 105 . The derived predicates are on the join predicates between the materialized results and the earliest related table accessed in the join sequence.

With join predicates of F.KEY_D 1 =D 1 .KEY_D 1 and F.KEY_D 3 =D 3 .KEY_D 3 , and the runtime outcome of materializing the snowflake tables, the following predicates can be derived to be applied against the fact table: AND F.KEY_D 1 BETWEEN 87 AND 531; and AND F.KEY_D 3 IN (103, 179, 216, 246, 262, 499). The result is a reduction in the rows that qualify from the fact table, and therefore fewer rows are joined after the fact table. This can provide a significant enhancement since data warehouse queries may access many millions of rows against a fact table, and therefore any filtering can reduce this number.

An improved method for processing a multiple table query has been disclosed. The method accesses and evaluates the filtering of any tables in a query that require or can benefit from materialization. Predicates based on the join predicates after filtering are then derived. While materializing and sorting, the derived predicates are applied to tables earlier in the join sequence. This significantly reduces the number of rows that are joined before arriving at the final result.

Although the present invention has been described in accordance with the embodiments shown, one of ordinary skill in the art will readily recognize that there could be variations to the embodiments and those variations would be within the spirit and scope of the present invention. Accordingly, many modifications may be made by one of ordinary skill in the art without departing from the spirit and scope of the appended claims.

Claims as granted

12 claims

Log in to read the claims of this application.

Log in to unlock

Classifications

5 codes
IPC · International Patent Classification
Section G — Physics
  • G06F17/30
USPC · US Patent Classification
707/2707/102707/3707/10

Claim changes

Soon
Coming soonHow the claims changed between publication and grant

See which claims were amended, added or cancelled during examination, with every added and removed word marked.

AmendedAddedCancelledUnchanged

The published claims of this application are not paired with the granted ones in what we hold.

File wrapper

⤢ drag to zoomJan 2005Jul 2005Jan 2006Jul 2006Jan 2007Jul 2007Jan 2008Jul 2008Jan 2009Jul 2009USPTOApplicantNon-final rejectionResponse after non-finalRequest for continued examinationResponse after non-final
USPTOApplicanthover for detail · click to open
Pendency
4.4 y
1,616 days filing → grant
Office actions
3
non-final + final
Responses
2
1 RCE
Examiner
Apu M Mofiz
art unit 2161 · TC 2100
Citations: 59 back · 9 forward

See the full prosecution history — every USPTO and applicant action on this file, in order.

Log in to unlock

Documents

Log in to open the documents of this file: the application as filed, every office action and response, the notice of allowance.

Log in to unlock

Chain of title

⤢ drag to zoom2006200820102012201420162018202020222024Owner 1
Titlehover for detail · click to open

See the full assignment history — every owner this patent has passed through, with recordation dates and reel/frame numbers.

Log in to unlock