9 Copyright © 2006, Oracle. All rights reserved. Summary Management.

Slides:



Advertisements
Similar presentations
Using the SQL Access Advisor
Advertisements

Refreshing Materialized Views
10 Copyright © 2005, Oracle. All rights reserved. Dimensions.
12 Copyright © 2005, Oracle. All rights reserved. Query Rewrite.
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Data Definition Language (DDL)
BY LECTURER/ AISHA DAWOOD DW Lab # 2. LAB EXERCISE #1 Oracle Data Warehousing Goal: Develop an application to implement defining subject area, design.
Materialized Views.
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
IBM Software Group ® Recommending Materialized Views and Indexes with the IBM DB2 Design Advisor (Automating Physical Database Design) Jarek Gryz.
10 Copyright © 2009, Oracle. All rights reserved. Managing Undo Data.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
Leaving a Metadata Trail Chapter 14. Defining Warehouse Metadata Data about warehouse data and processing Vital to the warehouse Used by everyone Metadata.
On-Line Analytic Processing Chetan Meshram Class Id:221.
OnLine Analytical Processing (OLAP)
Materialized Views Acknowledgement to Author: Willie Albino.
Materialized Views. 2 Materialized Views – Agenda What is a Materialized View? – Advantages and Disadvantages How Materialized Views Work – Parameter.
3 Copyright © 2005, Oracle. All rights reserved. Partitioning Basics.
1 Copyright © 2004, Oracle. All rights reserved. Introduction.
Using SQL to Query Oracle OLAP Cubes Bud Endress Director of Product Management, OLAP.
BI Terminologies.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Designing Aggregations. Performance Fundamentals - Aggregations Pre-calculated summaries of data Intersections of levels from each dimension Tradeoff.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
UNIT-II Principles of dimensional modeling
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.
CMPE 226 Database Systems October 21 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
13 Copyright © Oracle Corporation, All rights reserved. Maintaining Data Integrity.
7 Strategies for Extracting, Transforming, and Loading.
Chapter 4 Logical & Physical Database Design
Managing Schema Objects
Chapter 5 Index and Clustering
Accounting Events.
20 Copyright © 2008, Oracle. All rights reserved. Cache Management.
Session id: Darrell Hilliard Senior Delivery Manager Oracle University Oracle Corporation.
1 Copyright © 2009, Oracle. All rights reserved. Oracle Business Intelligence Enterprise Edition: Overview.
Oracle Business Intelligence Foundation - Commonly Used Features in Repository.
Unit 6 Seminar. Indexed Organized Tables Definition: Index Organized Tables are tables that, unlike heap tables, are organized like B*Tree indexes.
Lecture 15: Query Optimization. Very Big Picture Usually, there are many possible query execution plans. The optimizer is trying to chose a good one.
22 Copyright © 2009, Oracle. All rights reserved. Filtering Requests in Oracle Business Intelligence Answers.
Chapter 15 Materialized Views.
5 Copyright © 2008, Oracle. All rights reserved. Testing and Validating a Repository.
1 Copyright © Oracle Corporation, All rights reserved. Business Intelligence and Data Warehousing.
The Need for Data Analysis 2 Managers track daily transactions to evaluate how the business is performing Strategies should be developed to meet organizational.
8 Copyright © 2005, Oracle. All rights reserved. Gathering Statistics.
14 Copyright © 2004, Oracle. All rights reserved. Using Materialized Views.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support Chapter 25.
1 Copyright © 2006, Oracle. All rights reserved. Defining OLAP Concepts.
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
Copyright © 2006, Oracle. All rights reserved. Czinkóczki László oktató Using the Oracle Warehouse Builder.
3 Copyright © 2006, Oracle. All rights reserved. Building an Analytic Workspace.
7 Copyright © 2006, Oracle. All rights reserved. Defining a Relational Dimensional Model.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
1 Copyright © 2008, Oracle. All rights reserved. Repository Basics.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
7 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
15 Copyright © Oracle Corporation, All rights reserved. Managing Users.
10 Copyright © 2007, Oracle. All rights reserved. Managing Undo Data.
Using Partitions and Fragments
Materialized Views Willie Albino May 15, 2003.
SQL Views Presented by: Dr. Samir Tartir
Presentation transcript:

9 Copyright © 2006, Oracle. All rights reserved. Summary Management

Copyright © 2006, Oracle. All rights reserved Objectives After completing this lesson, you should be able to do the following: Discuss summary management and Oracle implementation of summaries Describe materialized views Identify the types, build modes, and refresh methods for materialized views Explain the query rewrite mechanism in Oracle Describe the significance of Oracle dimensions

Copyright © 2006, Oracle. All rights reserved Summary Management Need How can you improve query’s response time? –Using indexes –Partitioning your data What about precomputing query results? Create summaries: –Use normal tables before Oracle8 i : — Need to rewrite applications — Need to manually maintain data –Use materialized views beginning with Oracle8 i : — Automatically rewrite SQL applications. — Automatically refresh data.

Copyright © 2006, Oracle. All rights reserved Summary Management Summary management: –Improves query response time –Is the key to the performance of data warehouses A summary is a table that: –Stores preaggregated and prejoined data –Is based on user query requirements

Copyright © 2006, Oracle. All rights reserved Summary Navigation Effective use of summary tables requires summary table awareness. Methods for summary navigation: –Warehouse database engine –Proprietary summary-aware products –Open summary-aware middleware –3GL and metadata solutions select total_sales... Which summaries?

Copyright © 2006, Oracle. All rights reserved Managing Historical Summary Data in the Warehouse /1998 Last 12 months daily detail Monthly summary data Quarterly summary data Yearly summary data

Copyright © 2006, Oracle. All rights reserved Summary Management in Oracle Database 10g Materialized views: –Store precomputed aggregates and joins. –Results are stored in the database. –Use query rewrite. –Improve query performance. Summary Advisor: –Is a collection of functions and procedures (the DBMS_OLAP package) –Helps in defining and analyzing materialized views DBMS_OLAP

Copyright © 2006, Oracle. All rights reserved. 9- 8

Copyright © 2006, Oracle. All rights reserved Before Materialized Views SELECT c.cust_id, SUM(amount_sold) FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id; CREATE TABLE cust_sales_sum AS SELECT c.cust_id, SUM(amount_sold) AS amount FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id; SELECT * FROM cust_sales_sum;

Copyright © 2006, Oracle. All rights reserved After Materialized Views CREATE MATERIALIZED VIEW cust_sales_mv ENABLE QUERY REWRITE AS SELECT c.cust_id, SUM(amount_sold) AS amount FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id; SELECT c.cust_id, SUM(amount_sold) FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id; SELECT STATEMENT TABLE ACCESS (FULL) OF cust_sales_mv

Copyright © 2006, Oracle. All rights reserved Types of Materialized Views Materialized views with aggregates Materialized views containing only joins CREATE MATERIALIZED VIEW cust_sales_mv AS SELECT c.cust_id, s.channel_id, SUM(amount_sold) AS amount FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id, s.channel_id; CREATE MATERIALIZED VIEW sales_products_mv AS SELECT s.time_id, p.prod_name FROM sales s, products p WHERE s.prod_id = p.prod_id(+);

Copyright © 2006, Oracle. All rights reserved Nested Materialized Views A materialized view whose definition is based on another materialized view Definition that can also reference normal tables Common data warehouse situation: products sales times sales_time_prod_mv products sales times sales_prod_time_mv products sales times sales_prod_time_join sales_time_prod_mv sales_prod_time_mv

Copyright © 2006, Oracle. All rights reserved Materialized View: Example CREATE MATERIALIZED VIEW cust_sales_mv PCTFREE 0 TABLESPACE summ STORAGE (initial 1M next 1M pctincrease 0) BUILD DEFERRED REFRESH COMPLETE ENABLE QUERY REWRITE USING NO INDEX AS SELECT c.cust_id, s.channel_id, SUM(amount_sold) AS amount FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id, s.channel_id ORDER BY c.cust_id, s.channel_id; Name Storage options When to build it How to refresh the data Use this for query rewrite Detail query Detail tables MV keys Do not create an index

Copyright © 2006, Oracle. All rights reserved Materialized Views: Build Modes BUILD DEFERRED: MV created but not populated BUILD IMMEDIATE: MV created and populated ON PREBUILT TABLE : –Existing table is converted to MV : Same name and same schema. –Table is retained after MV is dropped. –Column aliases in detail query must correspond. –Detail tables and kidnapped table columns data types must match exactly by default. — WITH[OUT] REDUCED PRECISION clause –It is possible to have unmanaged columns in the table. – MV ’s STALENESS is set to UNKNOWN. BUILD_MODE in DBA_MVIEWS

Copyright © 2006, Oracle. All rights reserved Materialized Views: Refresh Methods COMPLETE FAST FORCE NEVER

Copyright © 2006, Oracle. All rights reserved Materialized Views: Refresh Modes ON DEMAND : Manual ON COMMIT : –Refresh is done at transaction commit. –It is possible only for fast-refreshable materialized views. –In case of failure, subsequent refreshes are manual. Schedule: At regular intervals

Copyright © 2006, Oracle. All rights reserved Query Rewrite Mechanism in Oracle Database Choose (based on cost) Generate plan RewriteGenerate plan Execute

Copyright © 2006, Oracle. All rights reserved Query Rewrite Execute query: SELECT c.cust_id, s.channel_id, SUM(amount_sold) AS amount FROM sales s, customers c WHERE s.cust_id = c.cust_id GROUP BY c.cust_id, s.channel_id Observe the execution plan: OPERATION NAME SELECT STATEMENT TABLE ACCESS FULL cust_sales_mv

Copyright © 2006, Oracle. All rights reserved Guidelines for Creating Materialized Views Define a single materialized view including all measures. Include COUNT(x) when using the aggregating measure AVG(x).

Copyright © 2006, Oracle. All rights reserved How to Find the Best Materialized Views? One materialized view can be used to satisfy multiple queries. Multiple materialized views can satisfy the same query. A balance between performance and space usage must be found. Which one is the best? –Analyze your workload. –Use Summary Advisor. –Use EXPLAIN_REWRITE to see why a materialized view is used or ignored.

Copyright © 2006, Oracle. All rights reserved Why Are Dimensions Important? Dimensions are data dictionary structures that have zero or more hierarchies based on existing columns. Create more hierarchies in dimensions for the following reasons: –They enable additional query rewrites without the use of constraints. –They help document hierarchies. –They can be used by online analytical processing (OLAP) tools.

Copyright © 2006, Oracle. All rights reserved Month_Desc Attribute Year_Key Quarter_Key Month_Key Dimensions and Hierarchies ALL Calendar hierarchy Sales_Date Level keys

Copyright © 2006, Oracle. All rights reserved Dimension Example Table TIME - YEAR_KEY - QUARTER_KEY - MONTH_KEY - MONTH_DESC - SALES_DATE Dimension TIME_DIM - YR - QTR - MON, MONTH_DESC - SDATE

Copyright © 2006, Oracle. All rights reserved Defining Dimensions and Hierarchies CREATE DIMENSION time_dim LEVEL sdate IS time.sales_date LEVEL mon IS time.month_key LEVEL qtr IS time.quarter_key LEVEL yr IS time.year_key HIERARCHY calendar_rollup ( sdate CHILD OF mon CHILD OF qtr CHILD OF yr ) ATTRIBUTE mon DETERMINES month_desc; Year Quarter Month Sales date

Copyright © 2006, Oracle. All rights reserved Dimensions with Multiple Hierarchies YR QTR MON YR WK DT Calendar hierarchy Week hierarchy = =

Copyright © 2006, Oracle. All rights reserved Rewrites Using Dimensions SELECT v.year, s.brand, s.city_name, SUM(s.tot_sales) FROM sales_sumry s, (SELECT distinct t.month, t.year FROM time t) v WHERE s.month = v.month GROUP BY v.year, s.brand, s.city_name; SELECT t.year, p.brand, c.city_name, SUM(s.amt) FROM sales s, city c, time t, product p WHERE s.sales_date = t.sdate AND s.city_name = c.city_name AND s.state_code = c.state_code AND s.prod_code = p.prod_code GROUP BY t.year, p.brand, c.city_name;

Copyright © 2006, Oracle. All rights reserved Summary In this lesson, you should have learned how to: Discuss summary management and Oracle implementation of summaries Describe materialized views Identify the types, build modes, and refresh methods for materialized views Explain the query rewrite mechanism in Oracle Describe the significance of Oracle dimensions

Copyright © 2006, Oracle. All rights reserved Practice 9-1: Overview This practice covers the following topics: Identifying the importance of summary management for RISD data warehouse Identifying the refresh strategy for the RISD materialized views Examining materialized views and other concepts discussed in the lesson

Copyright © 2006, Oracle. All rights reserved

Copyright © 2006, Oracle. All rights reserved