A data warehouse collects information from several possibly widely distributed and loosely coupled source databases. The collected information is integrated into a single database to be queried by the data warehouse clients.
Because a data warehouse is primarily used for decision support, queries at the data warehouse tend to be complex and take a long time to execute. Due to the huge volume of data and the complexity of the queries, a data warehouse is typically managed by a parallel database management system (DBMS). In addition to the data itself, the parallel DBMS typically includes data structures of various types that facilitate efficient query processing.
The data itself is organized in tables, also known as relations. Various data structures may be associated with these relations. For example, a view is a derived relation formed by performing a function on one or more base relations. Rather than storing the view, the function is typically recomputed each time the view is referenced.
A materialized view is another type of data structure used to speed up query processing. A materialized view is a pre-computed, stored query result that can be used for some queries instead of reconstructing the results directly from the base relations. As with the view, a function is performed on the base relations to derive the materialized view. Because the materialized view is stored, fast access to the data is possible without recomputing the view.
The materialized view is thus an assembly of data for fast access. After the materialized view is created, subsequent queries may use the materialized view, where appropriate, saving the overhead of performing the computation again. Materialized views may be used to assemble data that come from many different relations, which typically requires many different join operations to be performed between the relations.
Much like a cache, a materialized view is updated when the underlying base relations are modified. A typical materialized view may consist of a join between two or more base relations. The primary copy of the data is kept in the base relations. As these relations are changed through insertion of new tuples, deletion of tuples, or updates to existing tuples, the corresponding rows in the materialized view are changed to avoid becoming stale. This is known as materialized view maintenance.
The maintenance process may be expensive (in terms of resource utilization) on a parallel database management system. It is often the case that the information (tuples) for maintaining the materialized view is not stored together on a single node of the system. Thus, to perform a maintenance operation, the system collects the affected tuples together from several nodes, performs the join, and updates the materialized view. Maintenance of the materialized view may thus adversely affect the speed of query processing.
In a data warehouse environment, updates typically arrive in bulk, rather than a few at a time. Ostensibly, this bulk updating of data improves efficiency of the DBMS. In most commonly used commercial data warehousing systems, the data warehouse is not available for other queries during materialized view maintenance.
As international corporations have branches that span multiple time zones, there is sometimes no convenient “night” down time for the data warehouse to be maintained while blocking query requests. Moreover, in the world of e-commerce, there may be no down time.
Recently, real-time data warehousing has emerged. A real-time data warehouse is event driven, reacts in a timeframe appropriate to the business need, and makes rapid operational decisions or causes prompt operational actions. The real-time data warehouse must be available at all times to provide quick responses to interactive requests. Both updates to base relations and maintenance of materialized views ideally occur at least daily (and often hourly, every ten minutes, or even continuously). For a real-time data warehouse, therefore, materialized views need to be updated without inhibiting queries in progress.
According to the following embodiments, a method is described in which a tuple is received into a relation at a first node, wherein the tuple comprises a join attribute and the relation is not partitioned according to the join attribute. The tuple is stored in an auxiliary relation at a second node, wherein the auxiliary relation is partitioned according to the join attribute. Second tuples of a second relation are identified from the auxiliary relation of the second relation, joined with the tuple to produce one or more join results, and the join results are stored in a join view.
Other features and embodiments will become apparent from the following description, from the drawings, and from the claims.
In the following description, numerous details are set forth to provide an understanding of the present invention. However, it will be understood by those skilled in the art that the present invention may be practiced without these details and that numerous variations or modifications from the described embodiments may be possible.
In accordance with the following embodiments, a materialized view is maintained by using one or more auxiliary relations in a parallel DBMS. The auxiliary relations are derived from base relations in the parallel DBMS. The auxiliary relations keep track of predetermined “useful” parts (e.g., attributes appearing in the materialized view) of the base relations. Each auxiliary relation is organized to support maintenance of the materialized view. Accordingly, the performance of the maintenance operations may be improved for more efficient query processing.
Perhaps the most widely used materialized view is the join view. A join view stores and maintains the result from a join operation. Joins may be performed on two or more relations. Accordingly, a join view may be generated for multiple base relations.
Consider a join operation between two base relations A and B. An example of a join view JV for relations A and B on join attributes A.c and B.x may be described using the following structured query language (SQL) statement:
The SQL statement creates a join view JV from base relations A and B where attributes A.c and B.x are equal. The join view is partitioned on the attribute A.e. When an existing tuple is updated or deleted or a new tuple is inserted into a base relation, the join view JV that is derived from the base relation is also updated.
In one embodiment, auxiliary relations are used to maintain the join view JV. As depicted in
Additionally, in one embodiment, an index is maintained on each auxiliary relation. Index IA is maintained on attribute A.c for auxiliary relation ARA. Likewise, index IB is maintained on attribute B.x for auxiliary relation ARB. In
The auxiliary relations ARA and ARB are constructed based on a reorganization of the tuples TA and TB of base relations A and B, respectively, in which the join attributes (A.c and B.x) influence the construction. Auxiliary relations ARA and ARB thus include all the tuples of relations A and B, respectively, in which the tuples are simply rearranged.
In one embodiment, the data structures of
In
Likewise, a second relation, called relation B, includes tuples TB, also distributed on multiple nodes 14. One set of tuples 16a′ of relation B are on one node 14a while another set of tuples 16b′ of relation B are on another node 14b.
Both relations A and B may include additional tuples 16, distributed on additional nodes 14 of the parallel DBMS 100. In one embodiment, the tuples 16 of each relation 10 are distributed, as evenly as possible, across all the nodes 14 of the parallel DBMS 100. In
Although not depicted in
The tuples 16 for relations A and B are illustrated in
Looking back to the join view definition above, tuple TA of relation A is to be joined with one or more tuples TB of relation B in which attribute c of TA equals attribute x of one or more tuples TB. In one embodiment, the join operation is performed using, not relations A and B, but the auxiliary relations ARA and ARB. Then, the join result tuples are stored in the join view JV.
Recall that join views are recomputed each time a join operation is performed while materialized join views are stored and, thus, not recomputed. However, like a cache, a materialized join view must be maintained to be effective. This means that, as each existing tuple is updated or deleted or as each new tuple is inserted into the parallel DBMS, the materialized view is updated, so as not to become stale. The efficiency of maintenance of the materialized view depends on how the data is organized. Auxiliary relations are used to perform materialized join view maintenance, in accordance with some embodiments.
Take, for example, a join view JV, constructed from relations A and B, as in the above SQL statement. If base relations A and B are partitioned on the join attributes A.c and B.x, respectively, performing the join operation is relatively efficient, since tuples TA whose “c” attributes are equal to the “x” attribute of tuples TB are stored on the same node 14.
For example, in
Creating a join view JV according to the above SQL statement is relatively straightforward, since the tuples are stored at node i based upon the join attributes. Incoming tuple TA 40 may properly be joined with two tuples TB 50a and 50b, as the join attributes for these tuples meet the condition A.c=B.x. Accordingly two join result tuples 52, join result tuple 52a and join result tuple 52b, are created.
Where the join view JV is also partitioned according to either attribute “c” of relation A or attribute “x” of relation B, the join result tuples 52 may remain at node i. Where the join view JV is not partitioned on these attributes, however, the appropriate node(s) for the join result tuples 52 is (are) found, and the join result tuples 52 are sent to the appropriate node(s). Join result tuple 52a may be stored at the same node as join result tuple 52b or at a different node.
Thus, depending on how the join view JV is partitioned, one or more nodes may be involved in the join operation, even though relations A and B are partitioned according to the join attributes. If the join view JV is partitioned according to an attribute of relation A, the join result tuples 52 will all go to the same node. If the join view JV is partitioned according to some other strategy, such as according to attributes of relation B, the join result tuples 52 may each end up at different nodes.
The situation is worse when the base relations A and B are not partitioned on the join attributes. Instead of going to a node in which “like” tuples will be present, as depicted in
Another way of looking at join view maintenance is illustrated in
If, instead, the join view JV is not partitioned on an attribute of relation A, the distribution of join result tuples is depicted in
In
In
Materialized view maintenance may be inefficient and costly (in terms of system resources) where the base relations A and B are partitioned on attributes that are not join attributes (e.g.,
According to one embodiment, auxiliary relations are used to overcome the shortcomings of the join view maintenance techniques described above. In general, an auxiliary relation is maintained for each relation involved in the join operation. For the general case, it is assumed that neither base relation is partitioned on the join attribute. If, however, some base relation is partitioned on the join attribute, the auxiliary relation for that base relation is unnecessary, in one embodiment.
Where a join view JV is maintained from base relations A and B, two auxiliary relations, ARA for relation A, and ARB for relation B, are maintained. Relation ARA is a copy of relation A that is partitioned on the join attribute A.c. Relation ARB is a copy of relation B that is partitioned on the join attribute B.x. Additionally, as depicted in
By maintaining auxiliary relations ARA and ARB for relations A and B, respectively, assurance can be made that, at any node i of the parallel DBMS 100, tuples TA coexist with tuples TB in which the join attributes are of the same value (see
One procedure for maintaining a join view using auxiliary relations is depicted in
In
In
The operations of
In one embodiment, tuple TA (TB) is then joined with the appropriate tuples TB (TA) in ARB (ARA) at the second node (block 306). The join operation utilizes the index IB (IA) to quickly obtain tuples (block 306) that meet the join condition.
Subsequent operations depend on whether the join view JV is partitioned on an attribute of base relation A (B) or not (diamond 308). If so, join result tuples are sent to a third node based on the attribute value of TA (TB) (block 310). There, the join result tuples are inserted into the join view JV (block 314).
Where the join view JV is not partitioned on an attribute of base relation A (B), the join result tuples are distributed to multiple nodes based on the attribute value of the partitioning attribute of the join view JV (block 312). At each node to which the join result tuples are distributed, the join result tuples are inserted into the join view JV (block 314). The auxiliary relation method for maintaining the join view is thus complete, according to one embodiment.
The operations of
By using one or more auxiliary relations, the join view may be maintained more efficiently. In one embodiment, network communication is reduced. For each inserted (updated, deleted) tuple of base relation A, the join work to be done occurs at one node rather than at every node of the parallel DBMS 100. Further, for each inserted (updated, deleted) tuple of base relation A, the auxiliary relation ARB at one node (rather than at all nodes) is locked when performing the join operation. In one embodiment, this improves accessibility to the base relation B while join view maintenance is being performed.
Although creating and updating auxiliary relations in accordance with some embodiments results in extra work by the database system, the benefits they provide for maintaining materialized join views outweigh the costs.
Minimizing Storage Overhead
In one embodiment, the storage overhead for each auxiliary relation may be kept relatively small in many cases. For example, if a join view has some selection condition on the base relation A in the where clause, such as:
As another example, if a join view does not contain all attributes of the base relation A, such as:
Another example involves the join condition in the join view that is based on key and referential integrity restraints, such as:
where A.c is a key of relation A and B.x is a foreign key of relation B that references to A.c. If a tuple TA is inserted into relation A, there is no matching tuple in relation B that can be joined with TA. However, if a tuple TB is inserted into relation B, there must be a tuple of relation A that can be joined with it. The case for deletion is similar. Thus, in one embodiment, if only insertion and deletion in the base relations is considered, only the auxiliary relation ARA is maintained. There is no need for auxiliary relation ARB.
On the other hand, if a tuple TA of relation A is updated on a non-join attribute, to maintain the join view JV, tuple TA is joined with the appropriate tuples in the base relation B. In such an instance, the auxiliary relation ARB is helpful.
This example illustrates a dual use of the auxiliary relation. First, where the base relations are not partitioned on the join attributes, the auxiliary relations enable matching tuples satisfying the join criteria to reside on a single node. Using the auxiliary relation, the join operation may be more efficiently performed.
Second, the auxiliary relations are used to maintain the join view. Where, for example, the join condition in the join view is based on key and referential integrity restraints, as described above, only a partial benefit is obtained if one of the auxiliary relations is not generated.
In other words, a tradeoff exists between generating or not generating the auxiliary relation during the existence of the key and referential integrity constraints. If auxiliary relation ARB is not maintained, storage overhead is clearly saved. However, maintaining the join view JV will be costly in the case of an update in base relation A. If we keep the auxiliary relation ARB, maintaining the join view JV will be efficient, but ARB consumes some storage overhead.
In a data warehousing environment, it is common for certain base relations not to be updated. In such relations, tuples are either inserted or deleted from the base relations, e.g., the dimension tables of a star join. In one embodiment, to save storage overhead, auxiliary relation ARB is not maintained in a data warehousing environment.
Join View on Multiple Base Relations
In one embodiment, the auxiliary relation method for maintaining the materialized view may operate where the join view is defined on multiple base relations. Consider a join view that is defined on multiple base relations. If a base relation T is joined with multiple base relations R1, R2, . . . , and Rm in the join view definition, in one embodiment, an auxiliary relation of T is maintained for each Ri(1≦i≦m) that is partitioned on the join attribute between T and Ri(1≦i≦m).
For example, consider the following chain join:
However, it is possible that the number of auxiliary relations to be maintained is less than the above general case. For example, where the join conditions are between a key of Ri and a foreign key of Ri+1 that references to Ri(1≦i<n), a single auxiliary relation is maintained for each Ri(1<n) that is partitioned on the join attribute of RiRi+1 (rather than two auxiliary relations, one partitioned on the join attribute of Ri−1
Ri and another partitioned on the join attribute of Ri
Ri+1), according to one embodiment.
As another example, consider a star join where a large fact table is joined with a set of small dimension tables. A star join is a join of tables in a star schema. A star schema includes several dimension tables and a fact table. The fact table includes foreign keys that reference to primary keys of the dimension tables. In one embodiment, auxiliary relations for the fact table are not maintained, but only kept for each dimension table that is partitioned on the primary key.
Detecting Unnecessary Updates
Certain updates to the base relations will not cause the join view to change. In one embodiment, the system 100 detects these updates, such that unnecessary processing of the join view may be avoided.
Take, for example, a join view defined on base relations R1, R2, . . . , and Rn, in which base relation Ri is being updated. Consider each relation Rk that is joined with Ri in the join view definition. If the join condition of RiRk is between the key of and the foreign key of Rk that references to Ri, then insertions, deletions, and updates that change the join attribute of Ri
Rk do not cause the join view to be changed.
For example, suppose base relation A is updated and JV is defined as follows:
where A.c is a key of relation A and B.x is a foreign key of relation B that references to A.c. In one embodiment, for base relation A, insertions, deletions, and updates that change the attribute value of A.c do not cause the join view JV to be changed.
As another example, insertions, deletions, and updates to a base table that do not satisfy the selection condition in the where clause of the join view definition do not cause the join view to be changed, according to one embodiment. For example, suppose base relation A is updated and the join view JV is defined as follows:
Where a join view JV is defined on base relations R1, R2, . . . , and Rn, the system 100 determines the configuration of auxiliary relations that may be utilized to both compute join results and maintain the join view.
In one embodiment, for each base relation Rk that is joined with Ri in the join view definition (e.g., JV=RiRk . . . ), if Ri is not partitioned on the join attribute of Ri
Rk, according to one embodiment, an auxiliary relation of Ri that is partitioned on the join attribute of Ri
Rk is maintained.
Additionally, techniques already described to minimize storage overhead of the auxiliary relations may be employed. For example, unnecessary attributes are not stored in the auxiliary relations, in one embodiment. Tuples that do not satisfy the selection condition in the join view definition (e.g., A.e=3 in the example above) are not stored in the auxiliary relations. Finally, for those operations in which key and referential integrity constraints exist, maintenance of one or more auxiliary relations may be avoided, in some embodiments.
When a base relation Ri(1≦i≦n) is updated, certain operations may be performed to maintain the join view. For example in one embodiment, all the auxiliary relations of Ri are likewise updated. Further, unnecessary updates are avoided, where possible.
To detect unnecessary updates, assume that S is the set of all updates to Ri. Using the techniques described in the section, “Detecting Unnecessary Updates,” above, unnecessary updates are removed from S. If S is empty, the join view will not be changed, in one embodiment. Otherwise, for each base relation, R3 (j≠i, 1≦j≦n), the following operations are performed.
First, a proper auxiliary relation of Rj (or Rj itself) is determined, based on the join conditions. Changes to the join view are also computed according to the updates to Ri that are still left in the set S and the auxiliary (base) relation of Finally, the join view is updated.
For example, a join view JV may be defined on three base relations, A, B, and C, as follows:
JV=AB
C
Without loss of generality, assume that the base relations A, B, and C are not partitioned on the join attributes. Also assume that no technique is available for reducing the storage overhead of auxiliary relations.
In one embodiment, the following auxiliary relations are maintained:
(1) ARA for relation A that is partitioned on the join attribute of AB;
(2) ARB1 for relation B that is partitioned on the join attribute of AB;
(3) ARB2 for relation B that is partitioned on the join attribute of BC;
(4) ARC for relation C that is partitioned on the join attribute of BC;
These data structures are depicted in B. ARB2 and ARC are partitioned on the join attributes of B
C.
To maintain join view JV when a base relation is updated, three possibilities exist: base relation A is updated, base relation B is updated, or base relation C is updated. If a tuple TA is inserted into base relation A, the data structures of
In a second stage, the tuple TA is joined with one or more tuples TB1 from auxiliary relation ARB1, to produce one or more join result tuples 52. Since both ARA and ARB1 are partitioned on the join attributes of AB, stage 2 may be performed at the same node where tuple TA was stored in ARA.
At a third stage, the one or more join result tuples 52 are then joined with tuples TC of auxiliary relation ARC, according to one embodiment. Since ARC is partitioned on the join attribute of BC, for each join result tuple 52, the third stage may occur at a different node, in one embodiment, than the second stage.
If base relation B is updated with one or more tuples TB, tuples TB are likewise propagated to the auxiliary relations ARB1 and ARB2, according to one embodiment. ARA and ARC are used to maintain the join view JV.
Upon receiving a tuple TB, the data structures of
In a second stage, tuple TB is joined with one or more tuples TA from auxiliary relation ARA to produce one or more join result tuples 52. Since ARA and ARB1 are partitioned according to the same criteria (join attributes of AB), the operations of stage 2 are performed on the node where TB was stored in ARB1, in one embodiment.
In a third stage, the one or more join result tuples 52 are joined with one or more tuples TC in ARC, as illustrated in C), the operations of stage 3 are performed on the node where TB was stored in ARB2, in one embodiment.
Upon receiving a tuple TC, the data structures of
In a second stage, the tuple TC is joined with one or more tuples TB from auxiliary relation ARB2, to produce one or more join result tuples 52. Since both ARB2 and ARC are partitioned on the join attributes of BC, stage 2 may be performed at the same node where tuple TC was stored in ARC.
At a third stage, the one or more join result tuples 52 are then joined with tuples TA of auxiliary relation ARA, according to one embodiment. Since ARA is partitioned on the join attribute of AB, for each join result tuple 52, the third stage may occur at a different node, in one embodiment, than the second stage.
If the join condition includes one of the special cases described above, it is possible that fewer of the auxiliary relations may be used. Also, the storage overhead of the auxiliary relations may be reduced, in some embodiments.
For example, if the join condition of AB (B
C) is between a key of relation A (B) and a foreign key of relation B (C) that references to relation A (B), in one embodiment, the following auxiliary relations are maintained:
(1) ARA for relation A that is partitioned on the join attribute of AB;
(2) ARB for relation B that is partitioned on the join attribute of BC;
If tuples are inserted into or deleted from the base relation A (B), auxiliary relations ARA and ARB are updated and the join view JV remains unchanged. If tuples are inserted into or deleted from the base relation C, according to one embodiment, auxiliary relations ARA and ARB may be used to maintain the join view JV.
Additionally, the auxiliary relation method described herein may be implemented for a join view that is defined in the complete join of base relations A, B, and C. A complete join is one in which each of the base relations is joined with each of the other base relations. An equation for a complete join for base relations A, B, and C may look as follows:
Notice that relation A is joined with both relations B and C, whereas, in the previous example, relation A is only joined with relation B, not with relation C.
Where a complete join of relations A, B, and C is performed, six auxiliary relations, as depicted in
(1) ARA1 for relation A that is partitioned on the join attribute of AB
(2) ARB2 for relation B that is partitioned on the join attribute of AB
(3) ARB1 for relation B that is partitioned on the join attribute of BC
(4) ARC2 for relation C that is partitioned on the join attribute of BC
(5) ARC1 for relation C that is partitioned on the join attribute of CA
(6) ARA2 for relation A that is partitioned on the join attribute of CA
If a tuple TA is inserted into the base relation A, there are four possible ways to compute the corresponding changes to the join view JV, according to one embodiment:
(1) TA is joined with ARB2, then the join result tuples are joined with ARC2
(2) TA is joined with ARB2, then the join result tuples are joined with ARC1
(3) TA is joined with ARC1, then the join result tuples are joined with ARB1
(4) TA is joined with ARC1, then the join result tuples are joined with ARB2
The auxiliary relation method for maintaining the materialized view may likewise be performed with any number of base relations.
Aggregate Join View Extension
Another widely used materialized view is known as an aggregate join view. An aggregate join view is a join view that specifies some aggregate operations. An example of an aggregate join view AJV for relations A and B on join attributes A.c and B.x is as follows:
The various nodes and systems discussed each includes various software layers, routines, or modules. Such software layers, routines, or modules are executable on corresponding control units. Each control unit includes a microprocessor, a microcontroller, a processor card (including one or more microprocessors or microcontrollers), or other control or computing devices. As used here, a “controller” refers to a hardware component, software component, or a combination of the two.
The storage devices referred to in this discussion include one or more machine-readable storage media for storing data and instructions. The storage media include different forms of memory including semiconductor memory devices such as dynamic or static random access memories (DRAMs or SRAMs), erasable and programmable read-only memories (EPROMs), electrically erasable and programmable read-only memories (EEPROMs) and flash memories; magnetic disks such as fixed, floppy and removable disks; other magnetic media including tape; and optical media such as compact disks (CDs) or digital video disks (DVDs). Instructions that make up the various software routines, modules, or layers in the various devices or systems are stored in respective storage devices. The instructions when executed by a respective control unit cause the corresponding node or system to perform programmed acts.
The instructions of the software layers, routines or modules are loaded or transported to the corresponding system in one of many different ways. For example, code segments including instructions stored on floppy disks, CD or DVD media, a hard disk, or transported through a network interface card, modem, or other interface device are loaded into the system and executed as corresponding software routines or modules. In the loading or transport process, data signals that are embodied in carrier waves (transmitted over telephone lines, network lines, wireless links, cables, and the like) may communicate the code segments, including instructions, to the system. Such carrier waves may be in the form of electrical, optical, acoustical, electromagnetic, or other types of signals.
While the invention has been disclosed with respect to a limited number of embodiments, those skilled in the art will appreciate numerous modifications and variations therefrom. It is intended that the appended claims cover such modifications and variations as fall within the true spirit and scope of the invention.
This is a continuation of U.S. Ser. No. 09/900,280, entitled “Auxiliary Relation for Materialized View,” filed Jul. 6, 2001, now U.S. Pat. No. 7,092,951, which is incorporated by reference herein.
Number | Name | Date | Kind |
---|---|---|---|
5897632 | Dar et al. | Apr 1999 | A |
6026390 | Ross et al. | Feb 2000 | A |
6112198 | Lohman et al. | Aug 2000 | A |
6339769 | Cochrane et al. | Jan 2002 | B1 |
6345272 | Witkowski et al. | Feb 2002 | B1 |
6477534 | Acharya et al. | Nov 2002 | B1 |
6480836 | Colby et al. | Nov 2002 | B1 |
6484159 | Mumick et al. | Nov 2002 | B1 |
6493699 | Colby et al. | Dec 2002 | B2 |
6510422 | Galindo-Legaria et al. | Jan 2003 | B1 |
6532470 | Cochrane et al. | Mar 2003 | B1 |
6594653 | Colby et al. | Jul 2003 | B2 |
6889358 | Lieuwen et al. | May 2005 | B1 |
6990503 | Luo et al. | Jan 2006 | B1 |
6996554 | Kotsis et al. | Feb 2006 | B2 |
7092951 | Luo et al. | Aug 2006 | B1 |
7149737 | Luo et al. | Dec 2006 | B1 |
7155434 | Luo et al. | Dec 2006 | B1 |
20030093407 | Cochrane et al. | May 2003 | A1 |
Number | Date | Country | |
---|---|---|---|
Parent | 09900280 | Jul 2001 | US |
Child | 10848349 | US |