Documente Academic
Documente Profesional
Documente Cultură
Agenda
www.Delphix.com
28-Sep 2014
A short story
Background: DBA support for about 70 data warehouse databases at a
large telecommunications company
o Emails about out of space in TEMP tablespace scraped out of alert.log
file in a QA/TEST database
Offshore DBAs already reacting by killing sessions
o QA/TEST database already has 56G temp, and PROD has almost 300G
temp
o Reviewing AWR reports reveals a parallel aggregated query against a view
comprising a star schema between a fact table and 33 dimension tables
Further analysis reveals that none of the dimension-key columns on the fact
table supported by bitmap indexes
Thus, the star join consists of a partition-pruned FULL table scan on the fact,
followed by 33 HASH joins in parallel to the dimensions
www.Delphix.com
28-Sep 2014
A short story
When asked about the removed bitmap indexes
o An Informatica ETL developer commented
I dont know why all those indexes were removed
It was because the bitmap indexes made ETL data loading into the fact
table utterly impossible
o Project manager confirmed this, adding
Once the indexes were dropped, everything worked great
o DW architect added
This setup has been running in PROD for 10 months!
o In other words, everything is OK! Stop causing trouble!
www.Delphix.com
28-Sep 2014
www.Delphix.com
28-Sep 2014
Dimensional
Modeling
Customers
Suppliers
Orders
Products
Order Facts
Order Lines
www.Delphix.com
Customers Dim
Time Dim
28-Sep 2014
Dim
Table 1
Dim
Table 2
Dim
Table 3
Dim
Table 4
www.Delphix.com
Fact
table
Star transformation:
Filter on query set in
each dimension
Merge result set
from all dimensions
Join to the fact from
merged result set,
using BITMAP
MERGE index scan
28-Sep 2014
www.Delphix.com
28-Sep 2014
www.Delphix.com
28-Sep 2014
10
www.Delphix.com
28-Sep 2014
11
www.Delphix.com
28-Sep 2014
12
www.Delphix.com
28-Sep 2014
13
28-Sep 2014
14
Exchange Partition
The technique of bulk-loading new data into a temporary swap table,
which is then published using the EXCHANGE PARTITION operation,
should be the default load technique for all large tables in a data
warehouse
o fact tables
o slowly-changing dimensions
www.Delphix.com
28-Sep 2014
15
Composite-partitioned
table TXN
CREATE TABLE
TXN_SWAP
AS SELECT
FROM TXN
PARTITION
(P20140225)
22-Feb
2014
www.Delphix.com
23-Feb
2014
24-Feb
2014
25-Feb
2014
Oracle Open World 2014
28-Sep 2014
16
Composite-partitioned
table TXN
Load
Load
Load
22-Feb
2014
www.Delphix.com
23-Feb
2014
24-Feb
2014
25-Feb
2014
Oracle Open World 2014
28-Sep 2014
17
Composite-partitioned
table TXN
CREATE
INDEX
CREATE
INDEX
CREATE
INDEX
22-Feb
2014
www.Delphix.com
23-Feb
2014
24-Feb
2014
25-Feb
2014
Oracle Open World 2014
28-Sep 2014
18
Composite-partitioned
table TXN
EXCHANGE
PARTITION
22-Feb
2014
www.Delphix.com
23-Feb
2014
24-Feb
2014
25-Feb
2014
Oracle Open World 2014
28-Sep 2014
19
Composite-partitioned
table TXN
Gather
partition
statistics
for table,
columns,
indexes
22-Feb
2014
www.Delphix.com
23-Feb
2014
24-Feb
2014
25-Feb
2014
Oracle Open World 2014
28-Sep 2014
20
Exchange Partition
1. Create temporary table TXN_SWAP as a hash-partitioned table
2. Perform parallel, direct-path load of new data into TXN_SWAP
Perform any other DML needed to prepare data in TXN_SWAP
for publishing into the TXN table
3. Create indexes on TXN_SWAP corresponding to the local indexes
on TXN
4. Exchange partition to publish new data to TXN
alter table TXN
exchange partition P20140225 with table TXN_SWAP
including indexes update global indexes;
www.Delphix.com
28-Sep 2014
21
Exchange Partition
It is a good idea to encapsulate this logic inside PL/SQL packaged- or
stored-procedures:
SQL>
2
SQL>
SQL>
2
3
4
SQL>
SQL>
execute exchpart.prepare(TXN,_SWAP, -!
25-FEB-2014);!
alter session enable parallel dml;!
insert /*+ append parallel(n,4) */!
into txn_swap n!
select /*+ full(x) parallel(x,4) */ *!
from
stage_txn_fact x;!
commit;!
execute exchpart.finish(TXN,_SWAP);!
www.Delphix.com
28-Sep 2014
22
www.Delphix.com
28-Sep 2014
23
1.Use EXCHPART package to load the data for the 25-Feb and 24Feb partitions
2.Load the data to the remainder of the partitions by just
inserting (conventional-path) directly into the partitioned table
28-Sep 2014
24
28-Sep 2014
25
Slowly-changing dimensions
Loading time-variant fact and dimension tables is not the
only load activity in most data warehouses
o Often, some tables contain current or point-in-time data
Example: type-1 dimension derived from type-2 dimension
With each load cycle loading new data into a new partition
of the type-2 dimension, the type-1 dimension needs to be
updated
o Instead of performing transactional MERGE (i.e. Update or Insert)
logic directly on the table
Rebuild the table into a temporary table, then swap it in using
EXCHANGE PARTITION
www.Delphix.com
28-Sep 2014
26
28-Sep 2014
27
ACCT_DIM
(type-2 dimension)
ACCT_DIM_SWAP
Truncated as
we begin
Data
current
as of 24Feb
22-Feb
2014
23-Feb
2014
www.Delphix.com
24-Feb
2014
25-Feb
2014
28-Sep 2014
28
www.Delphix.com
28-Sep 2014
29
ACCT_DIM
(type-2 dimension)
All rows
All rows
22-Feb
2014
23-Feb
2014
www.Delphix.com
24-Feb
2014
ACCT_DIM_SWAP
union
all
filter
25-Feb
2014
28-Sep 2014
30
ACCT_DIM
(type-2 dimension)
ACCT_DIM_SWAP
CREATE
INDEX
CREATE
INDEX
CREATE
INDEX
22-Feb
2014
23-Feb
2014
www.Delphix.com
24-Feb
2014
25-Feb
2014
28-Sep 2014
31
ACCT_DIM
(type-2 dimension)
ACCT_DIM_SWAP
EXCHANGE
PARTITION
22-Feb
2014
23-Feb
2014
www.Delphix.com
24-Feb
2014
25-Feb
2014
28-Sep 2014
32
ACCT_DIM
(type-2 dimension)
ACCT_DIM_SWAP
Gather
partition
statistics
for table,
columns,
indexes
22-Feb
2014
23-Feb
2014
www.Delphix.com
24-Feb
2014
25-Feb
2014
28-Sep 2014
33
Summary
1. Data warehouses use star schemas
2. Star schemas are best queried using star
transformations
3. Star transformation requires bitmap indexes
o
28-Sep 2014
34
KScope15
http://www.KScope15.com
#ODTUG
#KScope15
Conference for EPM, APEX, ADF, BI, Oracle developers and DBAs
www.Delphix.com
28-Sep 2014
35
Q&A
Session:
Email:
Twitter:
Blog:
o Papers:
o Scripts:
o Videos:
www.Delphix.com
UGF-3587
Tim.Gorman@Delphix.com
@TimothyJGorman
EvDBT.com
EvDBT.com/papers
EvDBT.com/scripts
EvDBT.com/videos
28-Sep 2014
36