1. 1
28/12/2016
CREATING A BITMAP JOIN INDEXCREATING A BITMAP JOIN INDEXCREATING A BITMAP JOIN INDEXCREATING A BITMAP JOIN INDEX
PROBLEMPROBLEMPROBLEMPROBLEM
You’re working in a data warehouse environment. You have a fairly large
dimension table that is often joined to an extremely large fact table. You
wonder if there’s way to create a bitmap index in such a way that it can
eliminate the need for the optimizer to access the dimension table blocks to
satisfy the result of a query.
SOLUTIONSOLUTIONSOLUTIONSOLUTION
Here’s the basic syntax for creating a bitmap join index:
Create bitmap index <index_name>
On<fact_table> (dimension_table.dimension_column>)
From <fact_table>, <dimension_table>
Where <fact_table>.<foreign_key_column> =
<dimension_table>.<primary_key_column>;
Bitmap join indexes are apporopriate in situations where you’re joining two
tables using the foreign key column(s) in one table that relate to primary key
column(s) in another table. For example, suppose you tipically the CUST_NAME
from the D_CUSTOMERS table while joining to a large F_SHIPMENTS fact table.
This example creates a bitmap join index between the F_SHIPMENTS and
D_CUSTOMERS tables:
Create bitmap index f_shipments_bm_idx1
On f_shipments(d_customers.cust_name)
From f_shipments, d_customers
Where f_shipments.d_cust_id= d_customers.d_cust_id;
2. 2
Now, consider a query such this:
Select d_cust_name
From f_shipments f, d_customers d
Where f.d_cust_id= d.d_cust_id and d.cust_name =’Oracle’;
The optimizer can choose to use the bitmap join index and thus avoid the
expense of having to join the tables
HOW IT WORKSHOW IT WORKSHOW IT WORKSHOW IT WORKS
Bitmap join indexes store the results of a join between two tables in an index.
Bitmap indexes are beneficial because they avoid joining tables to retrieve
results. The syntax for a bitmap join index differs from a regular bitmap index
in that it contains FROM and WHERE clauses.
Bitmap join indexes are usually suitable on for data warehouse
environments where you have tables that get loaded and then are not
updated. When updating tables that have bitmap join indexes declared, this
potentially results in several rows being locked. Therefore this type of an
index is not suitable for an OLTP database.
3. 3
28/12/2016
CREAR UNCREAR UNCREAR UNCREAR UN BITMAP JOIN INDEXBITMAP JOIN INDEXBITMAP JOIN INDEXBITMAP JOIN INDEX
PROBLEMAPROBLEMAPROBLEMAPROBLEMA //// SITUACIONSITUACIONSITUACIONSITUACION
Estas trabajando en un entorno de almacén de datos. Tienes una tabla larga
de bastante dimensión que con frecuencia está unida con una tabla
extremadamente larga. Te preguntas si hay una manera para crear un Bitmap
index de tal manera que se puede eliminar por el optimizador si es necesario
para acceder a los bloques de la tabla para un resultado satisfactorio de la
query.
SOLUCIÓNSOLUCIÓNSOLUCIÓNSOLUCIÓN
La sintaxis básica para crear un bitmap join index es:
Create bitmap index <index_name>
On<fact_table> (dimension_table.dimension_column>)
From <fact_table>, <dimension_table>
Where <fact_table>.<foreign_key_column> =
<dimension_table>.<primary_key_column>;
Los Bitmap join indexes son apropiados cuando estas uniendo dos tablas
usando la foreign key column(s) en una tabla que se relaciona con la primary
key column(s) en otra tabla. Por ejemplo, suponga lo típico CUST_NAME de la
tabla D_CUSTOMERS mientras unes a un largo F_SHIPMENTS tabla. Este
ejemplo crea un bitmap join index entre las tablas F_SHIPMENTS y
D_CUSTOMERS:
4. 4
Create bitmap index f_shipments_bm_idx1
On f_shipments(d_customers.cust_name)
From f_shipments, d_customers
Where f_shipments.d_cust_id= d_customers.d_cust_id;
Ahora considere una query como la siguiente:
Select d_cust_name
From f_shipments f, d_customers d
Where f.d_cust_id= d.d_cust_id and d.cust_name =’Oracle’;
El optimizador puede elegir usar el bitmap join index y así evitar el coste de
tener que unir las tablas.
COMO SE TRABAJACOMO SE TRABAJACOMO SE TRABAJACOMO SE TRABAJA
Los Bitmap join indexes almacenan el resultado de una unión entre dos
tablas en un índice. Bitmap indexes son beneficiosos porque ellos evitan unir
tablas para obtener resultados. La sintaxis para un bitmap join index se
diferencia de un regular bitmap index en que contiene las clausulas FROM y
WHERE.
Bitmap join indexes normalmente son adecuados para un entornos de
almacenamiento de datos donde tienes tablas que cargas y no se actualizan.
Cuando actualizas las tablas que tienen declarado un bitmap join indexes,
potencialmente muestra el resultado de varias filas bloqueadas. Por lo tanto
este tipo de índices no son adecuados para una base de datos OLTP.
Traducción: B. Bautista