OOW08 Part
OOW08 Part
Who am I
Oracle DBA for 14
years and counting
z Speak at
conferences, write
articles, 4 books
z Brought up the Global
Database Group at
Starwood Hotels, in
White Plains, NY
z
10
9
11
12
13
14
z
z
z
When
z
z
z
Physical
Partition
Design
Easier Administration:
z Smaller
Performance:
z full
Data Purging
z DELETEs
Archival
z Usual
Partition Exchange
z Create
a temp table
z Create Indexes, etc.
Temp
z When done, issue:
Table
alter table T1 exchange
partition sp11 with
table tmp1;
z Data in TMP1 is available
sp11
sp12 sp13
partition p1
sp21
sp22
partition p2
sp31
sp32 sp33
partition p3
sp41
partition p4
Table
Partitioning What, When, Why and How by Arup Nanda
Backup Efficiency
z
10
Data Transfer
z
Traditional Approach
insert into target select *
from source@dblink
Transportable Tablespace
Source
Target
TST
TS1
it read only
z Copy the file
z "Plug in" the file as a new
tablespace into the target
database
z Can also be cross-platform
TST
TS1
z Make
11
Fast
Disk
Slow
Disk
TS1
ARC_TS
ASM Approach
12
How to Decide
z
z
Data Purging
Data Archival
Performance
Improving Backups
Data Movement
Ease of Administration
Different Type of Storage
Assign priorities
to each of these
objectives
13
Global-vs-Local Index
z
z
14
Case Study
Large Hotel Company
z Fictitious; any resemblance to real or
fictional entities is purely coincidental
z
15
Background
Hotel reservations made for future dates
z When guests check out, the CHECKOUTS
table is populated
z RESERVATIONS has RES_DT
z
z Is
16
Thought Process
Q: How will the tables be purged?
z A: Reservations are deleted 3 months after they
z
Decision:
z Since
17
Column
Since deletion is based on RES_DT and
CK_DT, those columns were chosen as
partitioning key for the respective tables
z Scripts:
z
18
Access Patterns
z
Decision:
z Use
19
Access Types
z
20
CHECKOUTS
CK_ID
Part CK_DT
UPD_DT
FOLIO_ID FK
GUESTS
FOLIOS
GST_ID
GST_NAME
FOLIO_ID
Part FOLIO_DT
RES_ID
TRANSACTIONS
FOLIO_ID
TRAN_ID
Part TRANS_DT
No FOLIO_DT column
Partitioning What, When, Why and How by Arup Nanda
21
CHECKOUTS
CK_ID
Part CK_DT
UPD_DT
FOLIO_ID FK
GUESTS
FOLIOS
GST_ID
GST_NAME
FOLIO_ID
Part FOLIO_DT
RES_ID
TRANSACTIONS
FOLIO_ID
TRAN_ID
TRANS_DT
Part FOLIO_DT
FOLIO_DT column
added
Partitioning was
What, When,
Why and How by Arup Nanda
22
Problem
Purge on CHECKOUTS, FOLIOS and
TRANSACTIONS is based on CK_DT, not
FOLIO_DT
z FOLIO_DT is the date of creation of the
record; CK_DT is updated date
z The difference could be months; so,
purging can't be done on FOLIO_DT
z Solution: Partitioning Key = CK_DT
z Add CK_DT to other tables
z
23
2nd Pass
RESERVATIONS
RES_ID
UPD_DT
Part RES_DT
GST_IDFK
CHECKOUTS
CK_ID
Part CK_DT
UPD_DT
FOLIO_ID FK
CK_DT column
was added
GUESTS
FOLIO
GST_ID
GST_NAME
FOLIO_ID
FOLIO_DT
RES_ID FK
Part CK_DT
TRANSACTIONS
FOLIO_ID FK
TRAN_ID
TRANS_DT
Part CK_DT
24
25
Problems, cont..
z
26
3rd Pass
RESERVATIONS
RES_ID
UPD_DT
Part RES_DT
GST_IDFK
CHECKOUTS
CK_ID
CK_DT
UPD_DT
FOLIO_ID FK
Part CK_DT
GUESTS
FOLIO
GST_ID
GST_NAME
FOLIO_ID
FOLIO_DT
RES_ID FK
Part CK_DT
TRANSACTIONS
FOLIO_ID FK
TRAN_ID
Part TRANS_DT
CK_DT column
was removed 27
Scenario #1
z
Created:
Table
Part Key UPD_DT Partition
RESERVATIONS 09/30
08/31 SEP08
z Guest
FOLIOS
checks in on 9/30
10/01
09/30
OCT08
2nd:
10/02
10/02
OCT08
OCT08
28
CK_DT in RES?
z
New Thought:
z Why
29
4th Pass
CK_DT
column
added
RESERVATIONS
CHECKOUTS
RES_ID
UPD_DT
PartCK_DT
RES_DT
GST_IDFK
CK_ID
CK_DT
UPD_DT
FOLIO_ID FK
Part CK_DT
GUESTS
FOLIO
GST_ID
GST_NAME
FOLIO_ID
FOLIO_DT
RES_ID FK
Part CK_DT
TRANSACTIONS
FOLIO_ID FK
TRAN_ID
Part TRANS_DT
30
Scenario #1 Modified
z
Created:
Table
Part Key UPD_DT Partition
RESERVATIONS 10/01
08/31 OCT08
New record
z Guest
FOLIOS
checks in on 9/30
10/01
09/30
OCT08
2nd:
10/02
10/02
10/02
OCT08
OCT08
OCT08
New record
New record
Update
31
Scenario #2
z
Created:
Table
Part Key UPD_DT Partition
RESERVATIONS 10/01
08/31 OCT08
New record
z Guest
FOLIOS
checks in on 9/30
10/01
09/30
OCT08
New record
1st:
11/01
11/01
11/01
11/01
NOV08
NOV08
NOV08
NOV08
New record
Row Migration
Row Migration
32
z Apps
change to apps
z No guarantee of logic
33
34
Non-Range Cases
z
million+ records
z No purge requirement
z No logical grouping of data. GUEST_ID is just
a meaningless number
z All dependent tables are accessed
concurrently, e.g. GUESTS and ADDRESSES
are joined by GUEST_ID
z
35
Hash Partitions
GUESTS table is hash partitioned on
GUEST_ID
z Number of Parts: in such a way that each
partition holds 2 million records
z Number of partitions must be a power of 2.
So 256 was chosen.
z All dependent tables like ADDRESSES
were also partitioned by hash (guest_id)
z
36
Hotels Tables
HOTELS table holds the names of the
hotels
z Several dependent tables exist
DESCRIPTIONS, AMENITIES, etc. all
joined to HOTELS by HOTEL_ID
z Partitioning by LIST?
z
37
Requirements:
z Very
small
z No regular purging needs
z Mostly static; akin to reference data
z Can't be read only; since programs update
them regularly.
z
Decision: No partitioning
38
Tablespace Decisions
z
tablespaces
z The same tablespace
z
z Too
39
Individual Tablespaces
Tablespaces named in line with partitions,
e.g. RES0809 holds partition Y08M09 of
RESERVATION table.
z Easy to make the tablespace READ ONLY
z Easy to backup backup only once
z Easy to ILM
z
40
Combined Solution
z
z If
41
Final Design
nt
rre th
Cu on
M
F2.dbf
F1.dbf
Tablespace TS0807
Y08M07
Y08M08
Y08M09
RESERVATIONS
Y08M07
Tablespace TS0808
Y08M08
Y08M07
Y08M08
Y08M09
Y08M09
CHECKOUTS
TRANSACTIONS
F1.dbf
F3.dbf
F4.dbf
F1.dbf
F5.dbf
F6.dbf
42
Backup
backed up
only once
READ
ONLY
F2.dbf
F1.dbf
Tablespace TS0807
Y08M07
Y08M08
Y08M09
nt
e
RESERVATIONS
rr th
u
C on
M
Y08M07
Tablespace TS0808
Y08M08
Y08M07
Y08M08
Y08M09
Y08M09
CHECKOUTS
TRANSACTIONS
F1.dbf
F3.dbf
F4.dbf
F1.dbf
F5.dbf
F6.dbf
43
ILM
slowest
medium
F2.dbf
F1.dbf
Tablespace TS0807
Y08M07
Y08M08
Y08M09
nt
e
RESERVATIONS
rr t h
u
C on
M
Y08M07
Tablespace TS0808
Y08M08
Y08M07
Y08M08
Y08M09
Y08M09
CHECKOUTS
TRANSACTIONS
fastest
F1.dbf
F3.dbf
F4.dbf
F1.dbf
F5.dbf
F6.dbf
44
Partitioning Tips
List the objectives of partitioning, in the
order of priority
z Try to make the same partitioning for all
related tables
z Try to introduce new columns
z Avoid Global Indexes
z
45
46
blog: arup.blogspot.com
Partitioning What, When, Why and How by Arup Nanda
47