Amazon Partner

Friday 16 July 2010

Configure a schema to support a star transformation query

What is Star Schema:
The star schema is perhaps the simplest data warehouse schema. It is called a star schema because the entity-relationship diagram of this schema resembles a star, with points radiating from a central table. The center of the star consists of a large fact table and the points of the star are the dimension tables.

Description of Figure 19-2 follows











Star Queries :-

A star query is a join between a fact table and a number of dimension tables. Each dimension table is joined to the fact table using a primary key to foreign key join, but the dimension tables are not joined to each other. The optimizer recognizes star queries and generates efficient execution plans for them. It is not mandatory to have any foreign keys on the fact table for star transformation to take effect.


Tuning Star Queries

To get the best possible performance for star queries, it is important to follow some basic guidelines:




  • A bitmap index should be built on each of the foreign key columns of the fact table or tables.
  • The initialization parameter STAR_TRANSFORMATION_ENABLED should be set to TRUE. This enables an important optimizer feature for star-queries. It is set to FALSEby default for backward-compatibility.

Once above conditions are satisfied majority of star queries in warehouse will use star transformation to provides very efficient query performance.


http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/schemas.htm#sthref1026



How Oracle Chooses to Use Star Transformation

The optimizer generates and saves the best plan it can produce without the transformation. If the transformation is enabled, the optimizer then tries to apply it to the query and, if applicable, generates the best plan using the transformed query. Based on a comparison of the cost estimates between the best plans for the two versions of the query, the optimizer will then decide whether to use the best plan for the transformed or untransformed version.

If the query requires accessing a large percentage of the rows in the fact table, it might be better to use a full table scan and not use the transformations. However, if the constraining predicates on the dimension tables are sufficiently selective that only a small portion of the fact table needs to be retrieved, the plan based on the transformation will probably be superior.

Note that the optimizer generates a subquery for a dimension table only if it decides that it is reasonable to do so based on a number of criteria. There is no guarantee that subqueries will be generated for all dimension tables. The optimizer may also decide, based on the properties of the tables and the query, that the transformation does not merit being applied to a particular query. In this case the best regular plan will be used.

Star Transformation Restrictions


  • Star transformation is not supported for tables with any of the following characteristics:

  • Queries with a table hint that is incompatible with a bitmap access path

  • Queries that contain bind variables

  • Tables with too few bitmap indexes. There must be a bitmap index on a fact table column for the optimizer to generate a subquery for it.

  • Remote fact tables. However, remote dimension tables are allowed in the subqueries that are generated.

  • Anti-joined tables

  • Tables that are already used as a dimension table in a subquery

  • Tables that are really unmerged views, which are not view partitions

  • The star transformation may not be chosen by the optimizer for the following cases:

  • Tables that have a good single-table access path

  • Tables that are too small for the transformation to be worthwhile

  • In addition, temporary tables will not be used by star transformation under the following conditions:

  • The database is in read-only mode

  • The star query is part of a transaction that is in serializable mode





No comments:

Post a Comment