Professional Documents
Culture Documents
CON2379 How To Use Oracle Database 12c Partitioning Features For Your Data Warehouse
CON2379 How To Use Oracle Database 12c Partitioning Features For Your Data Warehouse
12c Partitioning
for Data
Warehouses
OOW
OOW 2014
2014
Some
Background
My Story
Lead BI Engineer at
Past: Data Architect and BI Developer at
Intermountain Healthcare
President of Utah Oracle Users Group
IOUG 2014-15 Board Member
Collaborate 13 & 14 Conference
Committee
Utah State MIS Advisory Council Member
University of Utah Adjunct Professor
Past Contributing Editor of IOUG Select
Journal
Past Advisory Board Member of Healthcare
Data Warehousing Association
3
Monday, September29
Exadata SIG: 2:00 p.m. - 3:00 p.m.
BIWA SIG: 5:00 p.m. 6:00 p.m.
Tuesday, September 30
Internet of Things SIG: 11:00 a.m. - 12:00 p.m.
Storage SIG: 4:00 p.m. - 5:00 p.m.
SPARC/Solaris SIG: 5:00 p.m. - 6:00 p.m.
Wednesday, October 1
Oracle Enterprise Manager SIG: 8:00 a.m. - 9:00 a.m.
Big Data SIG: 10:30 a.m. - 11:30 a.m.
Oracle 12c SIG: 2:00 p.m. 3:00 p.m.
Oracle Spatial and Graph SIG: 4:00 p.m. (*OTN lounge)
ker
a
e
r Sp
o
f
l
Cal 10
5
1
TE ctober
A
R
O
LAB Ends O
L
O
C
Partitioning Background
First introduced in Oracle 8i
Enables large table to be split into
smaller pieces to improve
Performance
Availability
Manageability
Queries use partition pruning to only read
pertinent blocks
Partitioning Strategies
Range
List
Hash
Interval
Reference
Virtual Column
System
10
How We Use
Partitioning
11
Fact Tables
12
13
Special Cases
A few fact tables have more than one date field that
will be used frequently in queries
For examples, for sales we care about the ship date
and also the order date
Partition on date used the most
Global index on other date
14
IntervalReference
Partitioning
15
Interval-Reference Partitioning
Composite partition first by interval then
reference
Parent table creates new partitions when
data arrives
Child table is automatically maintained
Partition names inherited
16
17
18
19
20
21
22
23
Indexes
24
25
Partial Index
Index that only spans certain partitions,
not all
Works on local and global indexes
Can be overwritten at any time
26
Partial Index
28
29
Now create two LOCAL indexes; the first one is a partial index.
create index orders_idx1 on orders(order_number) local
indexing partial;
create index orders_idx2 on orders(col2) local;
index ORDERS_IDX1 created.
index ORDERS_IDX2 created.
And lets check out how these are defined in the Index
Partitions table.
select index_name, partition_name, status
from user_ind_partitions
where index_name in ('ORDERS_IDX1', 'ORDERS_IDX2');
30
Now lets create two GLOBAL indexes, the first one being a
partial index.
create index orders_idx3 on orders(col3)
indexing
partial;
create index orders_idx4 on orders(col4);
index ORDERS_IDX3 created.
index ORDERS_IDX4 created.
And now lets query the indexes table for these indexes.
select index_name, status, indexing
from user_indexes
where index_name in ('ORDERS_IDX3',
'ORDERS_IDX4');
31
32
33
Partition
Maintenance
34
35
Merge:
ALTER TABLE orders_range_part
MERGE PARTITIONS year_2010, year_2011, year_2012,
year_2013
INTO PARTITION historical_data_partition;
Split:
ALTER TABLE orders_range_part
SPLIT PARTITION year_2013 INTO
(year_2013_q1 VALUES LESS THAN to_date(04-012013, MM-DD-YYYY),
year_2013_q2 VALUES LESS THAN to_date(07-012013, MM-DD-YYYY),
year_2013_q3 VALUES LESS THAN to_date(10-012013, MM-DD-YYYY),
year_2013_q4);
36
37
38
Cascading Truncate
11g Truncate
12c Truncate
Parent
3
Parent
1
Child
1 1
Child
2 2
Child 2
Child 1
39
Exchange Partition
11g Exchange
New
Parent
Paren
New
Chil
Chil
Child
d1
d2
12c Exchange
New
Paren
t
Paren
t
Child
1
Child
2
40
New
Child
43
44
45
46
47
48
A few tips
If you want to change an existing partitioned table to interval
partitioning, you can execute this command:
ALTER TABLE <table name> SET INTERVAL
(numtoyminterval(1,'MONTH'));
With interval partitioning, to change the tablespace that new
partitions are stored in use:
ALTER TABLE <table name> SET STORE IN (<tablespace
name>);
49
Maintenance at Backcountry
50
????
Thank you.
Twitter: @mekolbe
Email: mkolbe@backcountry.com
51