Oracle9
i
Data Warehousing Guide
Release 1 (9.0.1)
June 2001
Part No. A90237-01
Oracle9i Data Warehousing Guide, Release 1 (9.0.1)
Part No. A90237-01
Copyright © 2001 Oracle Corporation. All rights reserved.
Primary Author: Paul Lane
Contributing Author: Viv Schupmann (Change Data Capture)
Contributors: Patrick Amor, Hermann Baer, Srikanth Bellamkonda, Randy Bello, Tolga Bozkaya, Benoit
Dageville, John Haydu, Lilian Hobbs, Hakan Jakobsson, George Lumpkin, Jack Raitto, Ray Roccaforte,
Gregory Smith, Ashish Thusoo, Jean-Francois Verrier, Gary Vincent, Andy Witkowski, Zia Ziauddin
Graphic Designer: Valarie Moore
The Programs (which include both the software and documentation) contain proprietary information of
Oracle Corporation; they are provided under a license agreement containing restrictions on use and
disclosure and are also protected by copyright, patent, and other intellectual and industrial property
laws. Reverse engineering, disassembly, or decompilation of the Programs is prohibited.
The information contained in this document is subject to change without notice. If you find any problems
in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this
document is error free. Except as may be expressly permitted in your license agreement for these
Programs, no part of these Programs may be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation.
If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on
behalf of the U.S. Government, the following notice is applicable:
Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial
computer software" and use, duplication, and disclosure of the Programs, including documentation,
shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement.
Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer
software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR
52.227-19, Commercial Computer Software - Restricted Rights (June, 1987). Oracle Corporation, 500
Oracle Parkway, Redwood City, CA 94065.
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently
dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup,
redundancy, and other measures to ensure the safe use of such applications if the Programs are used for
such purposes, and Oracle Corporation disclaims liability for any damages caused by such use of the
Programs.
Oracle is a registered trademark, and LogMiner,
Oracle9i, Oracle Call Interface, Oracle Database
Configuration Assistant, Oracle Enterprise Manager, Oracle interMedia, Oracle Net, Oracle Spatial, Oracle
Store, Oracle Text, Oracle Trace, PL/SQL, and Real Application Clusters, and SQL*Plus ar
e trademarks or
registered trademarks of Oracle Corporation. Other names may be trademarks of their respective
owners.
iii
Contents
Send Us Your Comments
................................................................................................................ xvii
Preface
.......................................................................................................................................................... xix
Part I Concepts
1 Data Warehousing Concepts
What is a Data Warehouse?............................................................................................................... 1-2
Subject Oriented............................................................................................................................ 1-2
Integrated....................................................................................................................................... 1-2
Nonvolatile .................................................................................................................................... 1-3
Time Variant.................................................................................................................................. 1-3
Contrasting OLTP and Data Warehousing Environments..................................................... 1-3
Data Warehouse Architectures......................................................................................................... 1-5
Data Warehouse Architecture (Basic)........................................................................................ 1-5
Data Warehouse Architecture (with a Staging Area).............................................................. 1-6
Data Warehouse Architecture (with a Staging Area and Data Marts) ................................. 1-7
Part II Logical Design
2 Logical Design in Data Warehouses
Logical versus Physical Design in Data Warehouses .................................................................. 2-2
Creating a Logical Design ................................................................................................................. 2-2
Data Warehousing Schemas ............................................................................................................. 2-3
iv
Star Schemas.................................................................................................................................. 2-4
Other Schemas............................................................................................................................... 2-4
Data Warehousing Objects................................................................................................................ 2-5
Fact Tables...................................................................................................................................... 2-5
Dimension Tables ......................................................................................................................... 2-6
Unique Identifiers......................................................................................................................... 2-7
Relationships ................................................................................................................................. 2-8
Typical Example of Data Warehousing Objects and Their Relationships............................ 2-8
Part III Physical Design
3 Physical Design in Data Warehouses
Moving from Logical to Physical Design....................................................................................... 3-2
Physical Design................................................................................................................................... 3-2
Physical Design Structures.......................................................................................................... 3-4
Tablespaces.................................................................................................................................... 3-4
Tables and Partitioned Tables..................................................................................................... 3-5
Views .............................................................................................................................................. 3-5
Integrity Constraints .................................................................................................................... 3-5
Indexes and Partitioned Indexes ................................................................................................ 3-6
Materialized Views....................................................................................................................... 3-6
Dimensions .................................................................................................................................... 3-6
4 Hardware and I/O Considerations in Data Warehouses
Overview of Hardware and I/O Considerations in Data Warehouses ..................................... 4-2
Why Stripe the Data?.................................................................................................................... 4-2
Automatic Striping ....................................................................................................................... 4-3
Manual Striping ............................................................................................................................ 4-4
Local and Global Striping............................................................................................................ 4-4
Analyzing Striping ....................................................................................................................... 4-6
RAID Configurations ......................................................................................................................... 4-9
RAID 0 (Striping) ........................................................................................................................ 4-10
RAID 1 (Mirroring)..................................................................................................................... 4-10
RAID 0+1 (Striping and Mirroring) ......................................................................................... 4-10
v
Striping, Mirroring, and Media Recovery............................................................................... 4-10
RAID 5.......................................................................................................................................... 4-11
The Importance of Specific Analysis........................................................................................ 4-12
5 Parallelism and Partitioning in Data Warehouses
Overview of Parallel Execution........................................................................................................ 5-2
When to Implement Parallel Execution..................................................................................... 5-2
Granules of Parallelism..................................................................................................................... 5-3
Block Range Granules.................................................................................................................. 5-3
Partition Granules......................................................................................................................... 5-4
Partitioning Design Considerations ............................................................................................... 5-4
Types of Partitioning.................................................................................................................... 5-4
Partition Pruning ........................................................................................................................ 5-13
Partition-wise Joins..................................................................................................................... 5-15
6 Indexes
Bitmap Indexes.................................................................................................................................... 6-2
Bitmap Join Indexes...................................................................................................................... 6-6
B-tree Indexes .................................................................................................................................... 6-10
Local Indexes Versus Global Indexes ........................................................................................... 6-10
7 Integrity Constraints
Why Integrity Constraints are Useful in a Data Warehouse ...................................................... 7-2
Overview of Constraint States ......................................................................................................... 7-3
Typical Data Warehouse Integrity Constraints............................................................................. 7-4
UNIQUE Constraints in a Data Warehouse ............................................................................. 7-4
FOREIGN KEY Constraints in a Data Warehouse................................................................... 7-5
RELY Constraints ......................................................................................................................... 7-6
Integrity Constraints and Parallelism........................................................................................ 7-7
Integrity Constraints and Partitioning ...................................................................................... 7-7
View Constraints .......................................................................................................................... 7-7
8 Materialized Views
Overview of Data Warehousing with Materialized Views......................................................... 8-2
vi
Materialized Views for Data Warehouses................................................................................. 8-2
Materialized Views for Distributed Computing ...................................................................... 8-3
Materialized Views for Mobile Computing.............................................................................. 8-3
The Need for Materialized Views .............................................................................................. 8-3
Components of Summary Management ................................................................................... 8-5
Terminology .................................................................................................................................. 8-7
Schema Design Guidelines for Materialized Views ................................................................ 8-8
Types of Materialized Views .......................................................................................................... 8-10
Materialized Views with Aggregates....................................................................................... 8-10
Materialized Views Containing Only Joins ............................................................................ 8-16
Nested Materialized Views ....................................................................................................... 8-18
Creating Materialized Views .......................................................................................................... 8-22
Naming......................................................................................................................................... 8-23
Storage Characteristics............................................................................................................... 8-23
Build Methods............................................................................................................................. 8-24
Enabling Query Rewrite ............................................................................................................ 8-24
Query Rewrite Restrictions ....................................................................................................... 8-25
Refresh Options........................................................................................................................... 8-26
ORDER BY Clause ...................................................................................................................... 8-30
Materialized View Logs............................................................................................................. 8-30
Using Oracle Enterprise Manager............................................................................................ 8-31
Using Materialized Views with NLS Parameters .................................................................. 8-31
Registering Existing Materialized Views..................................................................................... 8-32
Partitioning and Materialized Views............................................................................................ 8-34
Partition Change Tracking ........................................................................................................ 8-34
Partitioning a Materialized View ............................................................................................. 8-38
Partitioning a Prebuilt Table ..................................................................................................... 8-39
Rolling Materialized Views....................................................................................................... 8-40
Choosing Indexes for Materialized Views................................................................................... 8-40
Invalidating Materialized Views ................................................................................................... 8-41
Security Issues with Materialized Views..................................................................................... 8-41
Altering Materialized Views........................................................................................................... 8-42
Dropping Materialized Views........................................................................................................ 8-42
Analyzing Materialized View Capabilities ................................................................................. 8-43
Using the DBMS_MVIEW.EXPLAIN_MVIEW Procedure................................................... 8-43
vii
MV_CAPABILITIES_TABLE.CAPABILITY_NAME Details............................................... 8-46
MV_CAPABILITIES_TABLE Column Details ....................................................................... 8-48
Overview of Materialized View Management Tasks ................................................................ 8-49
9 Dimensions
What are Dimensions?....................................................................................................................... 9-2
Creating Dimensions ......................................................................................................................... 9-4
Multiple Hierarchies .................................................................................................................... 9-7
Using Normalized Dimension Tables ....................................................................................... 9-9
Dimension Wizard...................................................................................................................... 9-10
Viewing Dimensions........................................................................................................................ 9-10
Using The DEMO_DIM Package.............................................................................................. 9-10
Using Oracle Enterprise Manager............................................................................................ 9-11
Using Dimensions with Constraints............................................................................................. 9-11
Validating Dimensions.................................................................................................................... 9-12
Altering Dimensions........................................................................................................................ 9-13
Deleting Dimensions ....................................................................................................................... 9-14
Part IV Managing the Warehouse Environment
10 Overview of Extraction, Transformation, and Loading
Overview of ETL............................................................................................................................... 10-2
ETL Tools............................................................................................................................................ 10-3
Daily Operations......................................................................................................................... 10-4
Evolution of the Data Warehouse ............................................................................................ 10-4
11 Extraction in Data Warehouses
Overview of Extraction in Data Warehouses............................................................................... 11-2
Understanding Extraction Methods in Data Warehouses......................................................... 11-2
Logical Extraction Methods ...................................................................................................... 11-3
Physical Extraction Methods..................................................................................................... 11-4
Change Data Capture................................................................................................................. 11-5
Data Warehousing Extraction Examples ...................................................................................... 11-8
Extraction Using Data Files....................................................................................................... 11-8
viii
Extraction Via Distributed Operations .................................................................................. 11-11
12 Transportation in Data Warehouses
Overview of Transportation in Data Warehouses ...................................................................... 12-2
Understanding Transportation Mechanisms in Data Warehouses.......................................... 12-2
Transportation Using Flat Files ................................................................................................ 12-2
Transportation Through Distributed Operations .................................................................. 12-2
Transportation Using Transportable Tablespaces ................................................................. 12-3
13 Loading and Transformation
Overview of Loading and Transformation in Data Warehouses ............................................. 13-2
Transformation Flow.................................................................................................................. 13-2
Loading Mechanisms ....................................................................................................................... 13-4
SQL*Loader ................................................................................................................................. 13-5
External Tables............................................................................................................................ 13-6
OCI and Direct-path APIs ......................................................................................................... 13-8
Export/Import............................................................................................................................. 13-8
Transformation Mechanisms .......................................................................................................... 13-8
Transformation Using SQL ....................................................................................................... 13-9
Transformation Using PL/SQL .............................................................................................. 13-16
Transformation Using Table Functions................................................................................. 13-16
Loading and Transformation Scenarios...................................................................................... 13-26
Parallel Load Scenario.............................................................................................................. 13-26
Key Lookup Scenario ............................................................................................................... 13-34
Exception Handling Scenario.................................................................................................. 13-34
Pivoting Scenarios..................................................................................................................... 13-35
14 Maintaining the Data Warehouse
Using Partitioning to Improve Data Warehouse Refresh ......................................................... 14-2
Optimizing DML Operations During Refresh ........................................................................... 14-5
Implementing an Efficient Merge............................................................................................. 14-5
Maintaining Referential Integrity............................................................................................. 14-7
Purging Data................................................................................................................................ 14-8
Refreshing Materialized Views...................................................................................................... 14-9
ix
Complete Refresh ..................................................................................................................... 14-10
Fast Refresh ............................................................................................................................... 14-11
ON COMMIT Refresh.............................................................................................................. 14-11
Manual Refresh Using the DBMS_MVIEW Package .......................................................... 14-11
Refresh Specific Materialized Views with REFRESH.......................................................... 14-12
Refresh All Materialized Views with REFRESH_ALL_MVIEWS ..................................... 14-13
Refresh Dependent Materialized Views with REFRESH_DEPENDENT......................... 14-13
Using Job Queues for Refresh................................................................................................. 14-15
When Refresh is Possible......................................................................................................... 14-15
Recommended Initialization Parameters for Parallelism................................................... 14-15
Monitoring a Refresh ............................................................................................................... 14-15
Checking the Status of a Materialized View......................................................................... 14-16
Tips for Refreshing Materialized Views with Aggregates ................................................. 14-16
Tips for Refreshing Materialized Views Without Aggregates........................................... 14-19
Tips for Refreshing Nested Materialized Views .................................................................. 14-20
Tips After Refreshing Materialized Views............................................................................ 14-21
Using Materialized Views With Partitioned Tables................................................................. 14-22
Fast Refresh with Partition Change Tracking ...................................................................... 14-22
Fast Refresh with CONSIDER FRESH................................................................................... 14-26
15 Change Data Capture
About Oracle Change Data Capture ............................................................................................. 15-2
Publish and Subscribe Model ................................................................................................... 15-3
Example of a Change Data Capture System........................................................................... 15-4
Components and Terminology for Synchronous Change Data Capture........................... 15-5
Installation and Implementation................................................................................................... 15-8
Security ............................................................................................................................................... 15-8
Columns in a Change Table............................................................................................................ 15-8
Views................................................................................................................................................. 15-10
Synchronous Mode of Data Capture........................................................................................... 15-11
Publishing Change Data ............................................................................................................... 15-11
Subscribing to Change Data......................................................................................................... 15-13
Steps Required to Subscribe to Change Data ....................................................................... 15-13
What Happens to Subscriptions When the Publisher Makes Changes............................ 15-16
Export and Import Considerations.............................................................................................. 15-17
x
16 Summary Advisor
Overview of the Summary Advisor in the DBMS_OLAP Package ........................................ 16-2
Summary Advisor Wizard ........................................................................................................ 16-6
Using the Summary Advisor .......................................................................................................... 16-6
Identifier Numbers ..................................................................................................................... 16-7
Workload Management ............................................................................................................. 16-8
Loading a User-Defined Workload.......................................................................................... 16-9
Loading a Trace Workload...................................................................................................... 16-11
Loading a SQL Cache Workload ............................................................................................ 16-15
Validating a Workload............................................................................................................. 16-17
Removing a Workload ............................................................................................................. 16-18
Using Filters with the Summary Advisor ............................................................................. 16-18
Removing a Filter...................................................................................................................... 16-22
Recommending Materialized Views...................................................................................... 16-23
SQL Script Generation.............................................................................................................. 16-27
Summary Data Report ............................................................................................................. 16-29
When Recommendations are no Longer Required.............................................................. 16-31
Stopping the Recommendation Process ................................................................................ 16-32
Sample Sessions ........................................................................................................................ 16-32
Estimating Materialized View Size ............................................................................................. 16-37
ESTIMATE_MVIEW_SIZE Parameters ................................................................................. 16-37
Is a Materialized View Being Used?............................................................................................ 16-38
DBMS_OLAP.EVALUATE_MVIEW_STRATEGY Procedure ........................................... 16-39
Part V Warehouse Performance
17 Schema Modeling Techniques
Schemas in Data Warehouses ......................................................................................................... 17-2
Star Schemas................................................................................................................................ 17-2
Optimizing Star Queries ................................................................................................................. 17-4
Tuning Star Queries.................................................................................................................... 17-4
Using Star Transformation ........................................................................................................ 17-5
xi
18 SQL for Aggregation in Data Warehouses
Overview of SQL for Aggregation in Data Warehouses........................................................... 18-2
Analyzing Across Multiple Dimensions ................................................................................. 18-3
Optimized Performance ............................................................................................................ 18-4
An Aggregate Scenario .............................................................................................................. 18-5
Interpreting NULLs in Examples............................................................................................. 18-6
ROLLUP Extension to GROUP BY................................................................................................ 18-7
When to Use ROLLUP ............................................................................................................... 18-7
ROLLUP Syntax.......................................................................................................................... 18-7
Partial Rollup .............................................................................................................................. 18-8
CUBE Extension to GROUP BY ................................................................................................... 18-10
When to Use CUBE .................................................................................................................. 18-10
CUBE Syntax ............................................................................................................................. 18-10
Partial CUBE.............................................................................................................................. 18-12
Calculating Subtotals without CUBE .................................................................................... 18-13
GROUPING Functions.................................................................................................................. 18-13
GROUPING Function .............................................................................................................. 18-13
When to Use GROUPING ....................................................................................................... 18-16
GROUPING_ID Function........................................................................................................ 18-17
GROUP_ID Function................................................................................................................ 18-18
GROUPING SETS Expression..................................................................................................... 18-19
Composite Columns....................................................................................................................... 18-21
Concatenated Groupings............................................................................................................... 18-24
Concatenated Groupings and Hierarchical Data Cubes..................................................... 18-26
Considerations when Using Aggregation.................................................................................. 18-28
Hierarchy Handling in ROLLUP and CUBE........................................................................ 18-28
Column Capacity in ROLLUP and CUBE............................................................................. 18-29
HAVING Clause Used with GROUP BY Extensions .......................................................... 18-29
ORDER BY Clause Used with GROUP BY Extensions....................................................... 18-30
Using Other Aggregate Functions with ROLLUP and CUBE ........................................... 18-30
Computation Using the WITH Clause ....................................................................................... 18-30
19 SQL for Analysis in Data Warehouses
Overview of SQL for Analysis in Data Warehouses.................................................................. 19-2
Ranking Functions............................................................................................................................ 19-5
xii
RANK and DENSE_RANK ....................................................................................................... 19-5
Top N Ranking.......................................................................................................................... 19-12
Bottom N Ranking .................................................................................................................... 19-13
CUME_DIST .............................................................................................................................. 19-13
PERCENT_RANK..................................................................................................................... 19-14
NTILE ......................................................................................................................................... 19-15
ROW_NUMBER........................................................................................................................ 19-16
Windowing Aggregate Functions ................................................................................................ 19-17
Treatment of NULLs as Input to Window Functions.......................................................... 19-18
Windowing Functions with Logical Offset........................................................................... 19-18
Cumulative Aggregate Function ............................................................................................ 19-18
Moving Aggregate Function ................................................................................................... 19-19
Centered Aggregate Function................................................................................................. 19-20
Windowing Aggregate Functions with Logical Offsets...................................................... 19-21
Variable Sized Window ........................................................................................................... 19-22
Windowing Aggregate Functions with Physical Offsets.................................................... 19-23
FIRST_VALUE and LAST_VALUE........................................................................................ 19-24
Reporting Aggregate Functions ................................................................................................... 19-24
Reporting Aggregate Example................................................................................................ 19-26
RATIO_TO_REPORT ............................................................................................................... 19-27
LAG/LEAD Functions .................................................................................................................... 19-28
LAG/LEAD Syntax .................................................................................................................. 19-28
FIRST/LAST Functions.................................................................................................................. 19-29
FIRST/LAST Syntax................................................................................................................. 19-29
FIRST/LAST As Regular Aggregates.................................................................................... 19-30
FIRST/LAST As Reporting Aggregates ................................................................................ 19-31
Linear Regression Functions......................................................................................................... 19-32
REGR_COUNT.......................................................................................................................... 19-32
REGR_AVGY and REGR_AVGX ........................................................................................... 19-33
REGR_SLOPE and REGR_INTERCEPT................................................................................ 19-33
REGR_R2.................................................................................................................................... 19-33
REGR_SXX, REGR_SYY, and REGR_SXY............................................................................. 19-33
Linear Regression Statistics Examples................................................................................... 19-33
Sample Linear Regression Calculation.................................................................................. 19-34
Inverse Percentile Functions......................................................................................................... 19-35
xiii
Normal Aggregate Syntax....................................................................................................... 19-35
Inverse Percentile Restrictions................................................................................................ 19-38
Hypothetical Rank and Distribution Functions....................................................................... 19-39
Hypothetical Rank and Distribution Syntax ........................................................................ 19-39
WIDTH_BUCKET Function ......................................................................................................... 19-40
WIDTH_BUCKET Syntax........................................................................................................ 19-41
User-Defined Aggregate Functions ............................................................................................. 19-43
CASE Expressions........................................................................................................................... 19-44
Creating Histograms with User-defined Buckets................................................................ 19-45
20 Advanced Analytic Services
OLAP................................................................................................................................................... 20-2
Benefits of OLAP and RDBMS Integration............................................................................. 20-2
Data Mining....................................................................................................................................... 20-4
Enabling Data Mining Applications ........................................................................................ 20-5
Predictions and Insights ............................................................................................................ 20-5
Mining Within the Database Architecture.............................................................................. 20-5
Java API........................................................................................................................................ 20-7
21 Using Parallel Execution
Introduction to Parallel Execution Tuning................................................................................... 21-2
When to Implement Parallel Execution................................................................................... 21-2
Operations That Can Be Parallelized....................................................................................... 21-3
The Parallel Execution Server Pool .......................................................................................... 21-3
How Parallel Execution Servers Communicate ..................................................................... 21-5
Parallelizing SQL Statements.................................................................................................... 21-6
Types of Parallelism ....................................................................................................................... 21-11
Parallel Query ........................................................................................................................... 21-11
Parallel DDL.............................................................................................................................. 21-13
Parallel DML ............................................................................................................................. 21-18
Parallel Execution of Functions .............................................................................................. 21-28
Other Types of Parallelism...................................................................................................... 21-29
Initializing and Tuning Parameters for Parallel Execution .................................................... 21-30
Selecting Automated or Manual Tuning of Parallel Execution ......................................... 21-31
Using Automatically Derived Parameter Settings............................................................... 21-31
xiv
Setting the Degree of Parallelism ........................................................................................... 21-32
How Oracle Determines the Degree of Parallelism for Operations .................................. 21-34
Balancing the Workload........................................................................................................... 21-37
Parallelization Rules for SQL Statements.............................................................................. 21-38
Enabling Parallelism for Tables and Queries........................................................................ 21-46
Degree of Parallelism and Adaptive Multiuser: How They Interact ................................ 21-46
Forcing Parallel Execution for a Session................................................................................ 21-47
Controlling Performance with the Degree of Parallelism................................................... 21-48
Tuning General Parameters for Parallel Execution .................................................................. 21-48
Parameters Establishing Resource Limits for Parallel Operations.................................... 21-49
Parameters Affecting Resource Consumption ..................................................................... 21-58
Parameters Related to I/O....................................................................................................... 21-65
Monitoring and Diagnosing Parallel Execution Performance............................................... 21-67
Is There Regression?................................................................................................................. 21-68
Is There a Plan Change?........................................................................................................... 21-69
Is There a Parallel Plan?........................................................................................................... 21-69
Is There a Serial Plan? .............................................................................................................. 21-69
Is There Parallel Execution? .................................................................................................... 21-70
Is The Workload Evenly Distributed? ................................................................................... 21-70
Monitoring Parallel Execution Performance with Dynamic Performance Views........... 21-71
Monitoring Session Statistics .................................................................................................. 21-74
Monitoring System Statistics................................................................................................... 21-76
Monitoring Operating System Statistics................................................................................ 21-77
Affinity and Parallel Operations.................................................................................................. 21-77
Affinity and Parallel Queries .................................................................................................. 21-78
Affinity and Parallel DML....................................................................................................... 21-78
Miscellaneous Parallel Execution Tuning Tips ......................................................................... 21-79
Formula for Memory, Users, and Parallel Execution Server Processes............................ 21-80
Setting Buffer Pool Size for Parallel Operations................................................................... 21-82
Balancing the Formula ............................................................................................................. 21-82
Parallel Execution Space Management Issues...................................................................... 21-83
Overriding the Default Degree of Parallelism...................................................................... 21-84
Rewriting SQL Statements....................................................................................................... 21-85
Creating and Populating Tables in Parallel .......................................................................... 21-86
Creating Temporary Tablespaces for Parallel Sort and Hash Join.................................... 21-87
xv
Executing Parallel SQL Statements........................................................................................ 21-88
Using EXPLAIN PLAN to Show Parallel Operations Plans .............................................. 21-89
Additional Considerations for Parallel DML ....................................................................... 21-89
Creating Indexes in Parallel .................................................................................................... 21-93
Parallel DML Tips..................................................................................................................... 21-94
Incremental Data Loading in Parallel.................................................................................... 21-97
Using Hints with Cost-Based Optimization ....................................................................... 21-100
22 Query Rewrite
Overview of Query Rewrite............................................................................................................ 22-2
Cost-Based Rewrite .................................................................................................................... 22-3
When Does Oracle Rewrite a Query? ...................................................................................... 22-4
Enabling Query Rewrite.................................................................................................................. 22-7
Initialization Parameters for Query Rewrite .......................................................................... 22-8
Controlling Query Rewrite ....................................................................................................... 22-8
Privileges for Enabling Query Rewrite ................................................................................... 22-9
Accuracy of Query Rewrite..................................................................................................... 22-10
How Oracle Rewrites Queries...................................................................................................... 22-11
Text Match Rewrite Methods.................................................................................................. 22-12
General Query Rewrite Methods ........................................................................................... 22-13
When are Constraints and Dimensions Needed?................................................................ 22-14
Special Cases for Query Rewrite ................................................................................................. 22-45
Query Rewrite Using Partially Stale Materialized Views .................................................. 22-45
Query Rewrite Using Complex Materialized Views........................................................... 22-48
Query Rewrite Using Nested Materialized Views .............................................................. 22-48
Query Rewrite with CUBE, ROLLUP, and Grouping Sets................................................. 22-50
Did Query Rewrite Occur?............................................................................................................ 22-55
Explain Plan............................................................................................................................... 22-55
DBMS_MVIEW.EXPLAIN_REWRITE Procedure ............................................................... 22-56
Design Considerations for Improving Query Rewrite Capabilities .................................... 22-61
Constraints................................................................................................................................. 22-61
Dimensions................................................................................................................................ 22-61
Outer Joins................................................................................................................................. 22-61
Text Match ................................................................................................................................. 22-62
Aggregates................................................................................................................................. 22-62
xvi
Grouping Conditions ............................................................................................................... 22-62
Expression Matching................................................................................................................ 22-63
Date Folding .............................................................................................................................. 22-63
Statistics...................................................................................................................................... 22-63
Part VI Miscellaneous
A Glossary
B Sample Data Warehousing Schema
xvii
Send Us Your Comments
Oracle9
i
Data Warehousing Guide, Release 9.0.1
Part No. A90237-01
Oracle Corporation welcomes your comments and suggestions on the quality and usefulness of this
document. Your input is an important part of the information used for revision.
■
Did you find any errors?
■
Is the information clearly presented?
■
Do you need more information? If so, where?
■
Are the examples correct? Do you need more examples?
■
What features did you like most?
If you find any errors or have any other suggestions for improvement, please indicate the document
title and part number, and the chapter, section, and page number (if available). You can send com-
ments to us in the following ways:
■
Electronic mail:
■
FAX: (650) 506-7227 Attn: Server Technologies Documentation Manager
■
Postal service:
Oracle Corporation
Server Technologies Documentation
500 Oracle Parkway, Mailstop 4op11
Redwood Shores, CA 94065
USA
If you would like a reply, please give your name, address, telephone number, and (optionally) elec-
tronic mail address.
If you have problems with the software, please contact your local Oracle Support Services.
xviii
xix
Preface
This manual provides information about Oracle9i’s data warehousing capabilities.
This preface contains these topics:
■
Audience
■
Organization
■
Related Documentation
■
Conventions
■
Documentation Accessibility
xx
Audience
Oracle9i Data Warehousing Guide is intended for database administrators, system
administrators, and database application developers who perform the following
tasks:
■
design, maintain, and use data warehouses.
To use this document, you need to be familiar with relational database concepts,
basic Oracle server concepts, and the operating system environment under which
you are running Oracle.
Organization
This document contains:
Chapter 1, Data Warehousing Concepts
This chapter contains an overview of data warehousing concepts.
Chapter 2, Logical Design in Data Warehouses
This chapter discusses the logical design of a data warehouse.
Chapter 3, Physical Design in Data Warehouses
This chapter discusses the physical design of a data warehouse.
Chapter 4, Hardware and I/O Considerations in Data Warehouses
This chapter describes some hardware and input-output issues.
Chapter 5, Parallelism and Partitioning in Data Warehouses
This chapter describes the basics of parallelism and partitioning in data
warehouses.
Chapter 6, Indexes
This chapter describes how to use indexes in data warehouses.
Chapter 7, Integrity Constraints
This chapter describes some issues involving constraints.
xxi
Chapter 8, Materialized Views
This chapter describes how to use materialized views in data warehouses.
Chapter 9, Dimensions
This chapter describes how to use dimensions in data warehouses.
Chapter 10, Overview of Extraction, Transformation, and Loading
This chapter is an overview of the ETL process.
Chapter 11, Extraction in Data Warehouses
This chapter describes extraction issues.
Chapter 12, Transportation in Data Warehouses
This chapter describes transporting data in data warehouses.
Chapter 13, Loading and Transformation
This chapter describes transforming data in data warehouses.
Chapter 14, Maintaining the Data Warehouse
This chapter describes how to refresh in a data warehousing environment.
Chapter 16, Summary Advisor
This chapter describes how to use the Summary Advisor utility.
Chapter 17, Schema Modeling Techniques
This chapter describes the schemas useful in data warehousing environments.
Chapter 18, SQL for Aggregation in Data Warehouses
This chapter explains how to use SQL aggregation in data warehouses.
Chapter 19, SQL for Analysis in Data Warehouses
This chapter explains how to use analytic functions in data warehouses.
Chapter 20, Advanced Analytic Services
This chapter describes using analytic services in combination with Oracle9i.
xxii
Chapter 21, Using Parallel Execution
This chapter describes how to tune data warehouses using parallel execution.
Chapter 22, Query Rewrite
This chapter describes how to use Query Rewrite.
Appendix A, "Glossary"
This chapter defines commonly used data warehousing terms.
Appendix B, "Sample Data Warehousing Schema"
This chapter details the schema used throughout much of the book.
Related Documentation
For more information, see these Oracle resources:
■
Oracle9i Database Performance Guide and Reference
Many of the examples in this book use the sample schemas of the seed database,
which is installed by default when you install Oracle. Refer to Oracle9i Sample
Schemas for information on how these schemas were created and how you can use
them yourself.
In North America, printed documentation is available for sale in the Oracle Store at
/>Customers in Europe, the Middle East, and Africa (EMEA) can purchase
documentation from
/>Other customers can contact their Oracle representative to purchase printed
documentation.
To download free release notes, installation documentation, white papers, or other
collateral, please visit the Oracle Technology Network (OTN). You must register
online before using OTN; registration is free and can be done at
/>xxiii
If you already have a username and password for OTN, then you can go directly to
the documentation section of the OTN Web site at
/>For additional information, see:
■
The Data Warehouse Toolkit by Ralph Kimball (John Wiley and Sons, 1996)
■
Building the Data Warehouse by William Inmon (John Wiley and Sons, 1996)
Conventions
This section describes the conventions used in the text and code examples of the
this documentation set. It describes:
■
Conventions in Text
■
Conventions in Code Examples
Conventions in Text
We use various conventions in text to help you more quickly identify special terms.
The following table describes those conventions and provides examples of their use.
Convention Meaning Example
Bold Bold typeface indicates terms that are
defined in the text or terms that appear in
a glossary, or both.
When you specify this clause, you create an
index-organized table.
Italics Italic typeface indicates book titles or
emphasis.
Oracle9i Database Concepts
Ensure that the recovery catalog and target
database do not reside on the same disk.
UPPERCASE
monospace
(fixed-width
font)
Uppercase monospace typeface indicates
elements supplied by the system. Such
elements include parameters, privileges,
datatypes, RMAN keywords, SQL
keywords, SQL*Plus or utility commands,
packages and methods, as well as
system-supplied column names, database
objects and structures, usernames, and
roles.
You can specify this clause only for a NUMBER
column.
You can back up the database by using the
BACKUP command.
Query the TABLE_NAME column in the USER_
TABLES data dictionary view.
Use the DBMS_STATS.GENERATE_STATS
procedure.
xxiv
Conventions in Code Examples
Code examples illustrate SQL, PL/SQL, SQL*Plus, or other command-line
statements. They are displayed in a monospace (fixed-width) font and separated
from normal text as shown in this example:
SELECT username FROM dba_users WHERE username = ’MIGRATE’;
The following table describes typographic conventions used in code examples and
provides examples of their use.
lowercase
monospace
(fixed-width
font)
Lowercase monospace typeface indicates
executables, filenames, directory names,
and sample user-supplied elements. Such
elements include computer and database
names, net service names, and connect
identifiers, as well as user-supplied
database objects and structures, column
names, packages and classes, usernames
and roles, program units, and parameter
values.
Note: Some programmatic elements use a
mixture of UPPERCASE and lowercase.
Enter these elements as shown.
Enter sqlplus to open SQL*Plus.
The password is specified in the orapwd file.
Back up the datafiles and control files in the
/disk1/oracle/dbs directory.
The department_id, department_name,
and location_id columns are in the
hr.departments table.
Set the QUERY_REWRITE_ENABLED
initialization parameter to true.
Connect as oe user.
The JRepUtil class implements these
methods.
lowercase
monospace
(fixed-width
font) italic
Lowercase monospace italic font
represents placeholders or variables.
You can specify the
parallel_clause
.
Run U
old_release
.SQL where
old_
release
refers to the release you installed
prior to upgrading.
Convention Meaning Example
[ ] Brackets enclose one or more optional
items. Do not enter the brackets.
DECIMAL (
digits
[ ,
precision
])
{ }
Braces enclose two or more items, one of
which is required. Do not enter the braces.
{ENABLE | DISABLE}
|
A vertical bar represents a choice of two
or more options within brackets or braces.
Enter one of the options. Do not enter the
vertical bar.
{ENABLE | DISABLE}
[COMPRESS | NOCOMPRESS]
Convention Meaning Example
xxv
... Horizontal ellipsis points indicate either:
■
That we have omitted parts of the
code that are not directly related to
the example
■
That you can repeat a portion of the
code
CREATE TABLE ... AS
subquery
;
SELECT
col1
,
col2
, ... ,
coln
FROM
employees;
.
.
.
Vertical ellipsis points indicate that we
have omitted several lines of code not
directly related to the example.
Other notation You must enter symbols other than
brackets, braces, vertical bars, and ellipsis
points as shown.
acctbal NUMBER(11,2);
acct CONSTANT NUMBER(4) := 3;
Italics
Italicized text indicates placeholders or
variables for which you must supply
particular values.
CONNECT SYSTEM/
system_password
DB_NAME =
database_name
UPPERCASE Uppercase typeface indicates elements
supplied by the system. We show these
terms in uppercase in order to distinguish
them from terms you define. Unless terms
appear in brackets, enter them in the
order and with the spelling shown.
However, because these terms are not
case sensitive, you can enter them in
lowercase.
SELECT last_name, employee_id FROM
employees;
SELECT * FROM USER_TABLES;
DROP TABLE hr.employees;
lowercase Lowercase typeface indicates
programmatic elements that you supply.
For example, lowercase indicates names
of tables, columns, or files.
Note: Some programmatic elements use a
mixture of UPPERCASE and lowercase.
Enter these elements as shown.
SELECT last_name, employee_id FROM
employees;
sqlplus hr/hr
CREATE USER mjones IDENTIFIED BY ty3MU9;
Convention Meaning Example