Documente Academic
Documente Profesional
Documente Cultură
Dave Moore
Neon Enterprise Software
Agenda
Archiving Defined
Requirements and Solutions
Oracle Archiving Strategies
Oracle Row Removal Options
Oracle Post Archive Operations
Dave
Oracle ACE
Using Oracle since 1991
Product Author at Neon Enterprise Software
Creator of OracleUtilities.com
Author of Oracle Utilities from Rampant
Tech Press
Core competencies include performance,
utilities and data management
INTELLIGENCE. INNOVATION. INTEGRITY
Database Archiving
Database Archiving:
The process of removing selected data records from
operational databases that are not expected to be referenced
again and storing them in an archive data store where
they can be retrieved if needed.
Purge
INTELLIGENCE. INNOVATION. INTEGRITY
Amount of Data
Volume of data
m
o
C
ia
l
p
ce
ot
r
P
ti
c
e
Length of retention
requirement
on
Time Required
30+ Yrs
Paper
Blueprints
Forms
Claims
Word
Excel
PDF
XML
IMS
DB2
ORACLE
SYBASE
SQL Server
IDMS
VSAM
Programs
UNIX Files
Outlook
Lotus Notes
Attachments
Sound
Pictures
Video
Create
Operational
Needed for
completing
business
transactions
Reference
Archive
Needed for
reporting
or expected
queries
Needed for
compliance
and business
protection
Discard
Operational Efficiency
Database Archiving can be undertaken to
improve operational efficiency
Large volumes of data can interfere with
production operations
efficiency of transactions
efficiency of utilities: BACKUP/RESTORE, REORG, etc.
Storage
Gartner: databases copied an average of 6 times!
Components of a
Database Archiving Solution
Production
Database
Data
Extract
Captured Structure
Archive Policies
Data Retention
Recall
Database
Data
Recall
Archive Store
Archive Data
Query Access
Metadata
Policies
History
Data &
Metadata
Archive
Administration
Archiving Requirements
Policy based archiving: logical selection
Keep data for very long periods of time
Store very large amounts of data in archive
Maintain Archives for ever changing operational systems
Become independent from Applications/DBMS/Systems
Protect authenticity of data
Access data when needed; as needed
Discard data after retention period automatically
Implications:
How:
For Example
Parts Master is
the parent table
to all other tables
STORAGE INFO
Part Number
Bin Number
Qty on Hand
Qty on Order
Qty Backorder
PARTS MASTER
Part Number
Type
Description
Unit Type
Cost
Price
Substitute Parts
ORDER INFO
Part Number
PO Number
Vendor ID
Quantity Ordered
Unit Cost
Date Ordered
Date Received
SUMMARY BY
QUARTER
Part Number
Year
Q1 Disbursed
Q2 Disbursed
Q3 Disbursed
Q4 Disbursed
DISBURSEMENT
Part Number
Dept. ID
CHIT ID
Qty Disbursed
Date Disbursed
How:
Implications:
How:
Implications:
How:
Implications:
How:
Implications:
How:
Discard Function
Why :
Implications:
How:
Database or Archive?
Keep in DB
Keep in Archive
Performance
Space
Compliance
Keep in Archive
Purge
Must be Available
Must Be Secure
Not Needed
Rolling Windows
Self Managing
Mostly based on DATE
Utilize DBMS Features
Partitioning
Transportable Tablespaces
Exchange Partition
Set tablespace read only
Expdp
Copy export file and data file
Data Profile
Storage Profile
Probably
Never
Accessed
Cheap as
you can get
Read Only /
Compressed
P47
Rarely
Accessed
Heavily
Accessed
Not so fast
or expensive
Fast,
expensive
Read Only
Read / Write
Import
Trans Tsp
Version 16Z
Year 2007
Year 2030
Rows Gotta Go
SQL DELETE
Good for small number of rows
RI handled automatically
Oracle was born to DELETE, better than any
PL/SQL that you write.
Issue with Un-indexed Foreign Keys
DELETE Optimization
Work in batches, committing (only when
programmatically DELETING)
Use parallel DML (Partitioned tables only)
Drop Indexes before (if possible)
Index FK columns
CTAS
Works well for PURGE, not archive
Perfect when you want to keep low percentage of
rows in the table
Doesnt handle RI no DELETE was issued.
Process
1.
2.
3.
Rename table
4.
Recreate indexes
TRUNCATE
Congratulations if your application lends
itself to TRUNCATE without losing new data
What about RI?
May truncate or drop individual partitions
DROP
DROP PARTITION
What would you do before you drop it?
Exchange partition with table
Transportable tablespace.
Things to Remember
Benchmark the best way for you
Benchmark against real data if possible
Use parallel DML
Design Summary
Create an architecture that lends itself to
aging, archiving, deleting
This architecture should compensate for
business requirements
2 Days Later
After DELETE
After Maintenance
Refresh Statistics
Help the optimizer, easy enough
dbms_stats provides many options
Automatic Stats
Recommended by Oracle
Calls DBMS_STATS_JOB_PROC
Enabled via:
Begin
dbms_auto_task_admin.enable(
client_name => auto optimizer stats collection,
operation => NULL,
window_name => NULL);
END;
/
Size Current
Poss.
FILE_NAME
Poss.
Size Savings
-------------------------------------------------- -------- -------- -------/export/home/ora102/oradata/ora102/qasb001.dbf
29
46
17
/export/home/ora102/oradata/ora102/example01.dbf
69
100
31
/export/home/ora102/oradata/ora102/qasb002.dbf
41
41
0
/export/home/ora102/oradata/ora102/system01.dbf
493
500
7
/export/home/ora102/oradata/ora102/sysaux01.dbf
430
430
0
/export/home/ora102/oradata/ora102/undotbs01.dbf
91
175
84
/export/home/ora102/oradata/ora102/users01.dbf
44
83
39
/export/home/ora102/oradata/ora102/test.dbf
51
70
19
Nothing Changed !
INTELLIGENCE. INNOVATION. INTEGRITY
Size Current
Poss.
FILE_NAME
Poss.
Size Savings
-------------------------------------------------- -------- -------- -------/export/home/ora102/oradata/ora102/qasb001.dbf
29
46
17
/export/home/ora102/oradata/ora102/example01.dbf
69
100
31
/export/home/ora102/oradata/ora102/qasb002.dbf
41
41
0
/export/home/ora102/oradata/ora102/system01.dbf
493
500
7
/export/home/ora102/oradata/ora102/sysaux01.dbf
430
430
0
/export/home/ora102/oradata/ora102/undotbs01.dbf
171
175
4
/export/home/ora102/oradata/ora102/users01.dbf
44
83
39
/export/home/ora102/oradata/ora102/test.dbf
1
70
69
drop
truncate
PARENT
COL1
ON DELETE CASCADE
CHILD
COL1
COL1_PARENT
1 Million Rows
Before Index
delete from parent
where
col1 < 1000
call
count
------- -----Parse
1
Execute
1
Fetch
0
------- -----total
2
cpu
elapsed
disk
query
current
-------- ---------- ---------- ---------- ---------0.01
0.08
2
27
0
0.90
0.80
4
2208799
6062
0.00
0.00
0
0
0
-------- ---------- ---------- ---------- ---------0.91
0.88
6
2208826
6062
rows
---------0
999
0
---------999
cpu
elapsed
disk
query
current
-------- ---------- ---------- ---------- ---------0.00
0.00
0
0
0
285.94
293.11
1543900
2208789
1029
0.00
0.00
0
0
0
-------- ---------- ---------- ---------- ---------285.94
293.11
1543900
2208789
1029
rows
---------0
999
0
---------999
cpu
elapsed
disk
query
current
-------- ---------- ---------- ---------- ---------0.00
0.00
0
0
0
0.53
0.47
7
13
7053
0.00
0.00
0
0
0
-------- ---------- ---------- ---------- ---------0.53
0.47
7
13
7053
rows
---------0
999
0
---------999
cpu
elapsed
disk
query
current
-------- ---------- ---------- ---------- ---------0.00
0.00
0
0
0
0.42
0.46
2
3002
4058
0.00
0.00
0
0
0
-------- ---------- ---------- ---------- ---------0.42
0.46
2
3002
4058
rows
---------0
999
0
---------999
Summary Points
Create sound Archiving strategy based on Oracle
technical features as well as business and/or
legal requirements
Leverage partitioning
Move partitions to cheap disk when appropriate
Make partitions read only and compressed
Remove data via DROP or TRUNCATE if possible
If SQL DELETE, make sure to perform
maintenance operations
Consider 3rd party solutions
INTELLIGENCE. INNOVATION. INTEGRITY