Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

Indexes

Bitmap Indexes on Partitioned Tables

Like other indexes, you can create bitmap indexes on partitioned tables. The only restriction is that bitmap indexes must be local to the partitioned table—they cannot be global indexes. Global bitmap indexes are supported only on nonpartitioned tables.

See Also:

Chapter 11, "Partitioned Tables and Indexes" for information about partitioned tables and descriptions of local and global indexes

Oracle9i Database Performance Tuning Guide and Reference for more information about using bitmap indexes

Bitmap Join Indexes

A join index is an index on one table that involves columns of one or more different tables through a join.

The bitmap join index, in its simplest form, is a bitmap index on a table F based on columns from table D1,...,Dn, where Di joins with F in a star or snowflake schema as described in "Creation of a Bitmap Join Index" on page 10-56. In the data warehousing environment, table F is usually a fact table, table Di is usually a dimension table, and the join condition is an equi-inner join between the primary key column(s) of the dimension tables and the foreign key column(s) in the fact table. For simplicity, from now on we call the table whose rowids are bitmapped the fact table, and the other tables participating in the join of bitmap join index the dimension tables.

The volume of data that must be joined can be reduced if join indexes are used as joins have already been precalculated. In addition, join indexes which contain multiple dimension tables can eliminate bitwise operations which are necessary in the star transformation with existing bitmap indexes. Finally, bitmap join indexes are much more efficient in storage than materialized join views which do not compress rowids of the fact tables.

Four Join Models

The following section describes four join models in the star query framework and explains how they are addressed by bitmap join indexes. The accompanying figures are described by SQL statements in the text that follows each figure.

Notation

Schema Objects 10-53

Indexes

Fi -- Fact table i

Di -- Dimension table i

pk -- The primary key column on the dimension table

fk -- The fact table column participating in the join with the dimension tables sales -- The measurement column on the fact table

Figure 10–12 One Dimension Table Column Joins One Fact Table

d.pk = f.fk

D

c1

F

In Figure 10–12, a bitmap join index on F(D.c1) can be represented by the following SQL statement:

CREATE BITMAP INDEX bji ON f (d.c1) FROM f, d WHERE d.pk = f.fk

Then the following query can be run by accessing the bitmap join index to avoid the join operation:

SELECT SUM(f.sales)

FROM d, f

WHERE d.pk = f.fk and d.c1 = 2

Similar to the materialized join view, a bitmap join index computes the join and stores it as a database object. The difference is that a materialized join view materializes the join into a table while a bitmap join index materializes the join into a bitmap index.

Figure 10–13 Two or More Dimension Table Columns Join One Fact Table

d.pk = f.fk

D

c1 c2

F

Figure 10–13 shows a simple extension of Figure 10–12, requiring a concatenated bitmap join index to represent it, as follows:

10-54 Oracle9i Database Concepts

Indexes

CREATE BITMAP INDEX bji ON f (d.c1, d.c2)

FROM F, d

WHERE d.pk = f.fk;

The result of the following query can be retrieved by accessing the bitmap join index bji.:

SELECT SUM(f.sales)

FROM d, f

WHERE d.pk = f.fk AND d.c1 = 1 AND d.c2 = 3;

Another query which references only the leading portion of the index key can also use bitmap join index bji:

SELECT SUM(f.sales)

FROM d, f

WHERE d.pk = f.fk AND d.c1 = 1

Figure 10–14 Multiple Dimension Tables Join One Fact Table

 

 

 

 

d1.pk = f.fk1

 

 

 

d2.pk = f.fk2

 

 

 

 

D1

 

c1

 

F

 

 

D2

c2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 10–14 shows the third model, which requires a concatenated bitmap join index:

CREATE BITMAP INDEX bji ON f (d1.c1, d2.c2)

FROM f, d1, d2

WHERE d1.pk = f.fk1 AND d2.pk = f.fk2

Schema Objects 10-55

Indexes

Figure 10–15 Snow Flake Schema

 

 

 

 

d1.pk = d2.c2

 

 

 

 

d2.pk = f.fk

 

 

 

 

D1

 

c3

 

D2

 

c2

 

F

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 10–15 involves joins between two or more dimension tables. It can be expressed by a bitmap join index. The bitmap join index can be either single or concatenated depending on the number of columns in the dimension tables to be indexed. A bitmap join index on d1.c3 with a join between d1 and d2 and a join between d2 and f can be created as follows:

CREATE BITMAP INDEX bji ON f (d1.c3)

FROM f, d1, d2

WHERE d1.pk = d2.c2 AND d2.pk = f.fk;

A bitmap join index should be able to represent joins of the combination of the preceding models.

Creation of a Bitmap Join Index

Consider a star or snowflake schema with a single fact table F and multiple dimension tables D1,.., Dn as defined in "Bitmap Join Indexes" on page 10-53. These are the restrictions on the bitmap join index on F joined with D1,.., Dn.

The bitmap join index is on a single table F.

No table can appear twice in the FROM clause.

Joins form either star or snowflake schema and all joins are through primary keys or keys with unique constraints as follows:

The dimension table column(s) participating the join with the fact table must be either the primary key column(s) or with the unique constraint

In the snow flake schema where a join is D1><D2><F, the column(s) on D1 participating in the join D1><D2 must be either the primary key column(s) or with the unique constraint.

For a composite primary key on the dimension table, each column of the key needs to be in the join.

All joins are equi-inner joins and they are connected by ANDs only.

10-56 Oracle9i Database Concepts

Соседние файлы в папке Oracle selected docs