0% found this document useful (0 votes)
52 views

Table Partitioning: An Example: Don Bertsch Live Oak Telecom Oracle DBA

This document outlines a process for partitioning an Oracle database table to improve performance and manageability. The process involves: 1) creating a partitioned copy of the table and indexes, 2) cutting over from the original table to the partitioned copy, and 3) maintaining the partitioned table as it grows over time. Key steps include building dummy tables and indexes to populate partitions, and swapping partitions to move data online.

Uploaded by

Bodea Florin
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Table Partitioning: An Example: Don Bertsch Live Oak Telecom Oracle DBA

This document outlines a process for partitioning an Oracle database table to improve performance and manageability. The process involves: 1) creating a partitioned copy of the table and indexes, 2) cutting over from the original table to the partitioned copy, and 3) maintaining the partitioned table as it grows over time. Key steps include building dummy tables and indexes to populate partitions, and swapping partitions to move data online.

Uploaded by

Bodea Florin
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Table Partitioning: An Example

Don Bertsch
Live Oak Telecom
Oracle DBA
Procedural Overview
• Create partitioned copy of table (including
indexes)
• Cutover from old table to new
• Drop original (non-partitioned) table
• Maintain new partitions as table grows
Requirements
• Disk space equivalent to that of space
occupied by non-partitioned table
• Version 8i or later of Oracle server
– Partitioning available in Oracle 8, but don't
know about exchange partition command
– Oracle 7 uses different method, based upon
views
STEP 1

Build Partitioned Table and


Indexes ( Incrementally)
Define Partitioned Table
• Create containing single partition
• Specify RANGE partitioning method
• Base on convenient time period
– do using VALUES LESS THAN clause
• Partition is initially empty
• Do not use MAXVALUE clause
• Create in same schema as non-partitioned table
• Give similar but different name
• Define structure exactly
– will be same as final table
• Metadata available, using exp/imp utility
Define Indexes, Constraints & Triggers
for Partitioned Table
• Give indexes similar but different names
• Make indexes local
– Do using LOCAL keyword
• When defining primary key, prefix using
partitioning key column
• If not already indexed, index the partition-
key column
Create Two Tablespaces
• One for Table Data
• Another for Index Data
• Make both dictionary managed
• Size appropriately
• Raid 5 Disks are fine.
Build Dummy Table and Indexes
• Table must be defined same as table partition
– Same number of columns
– Same column names
– Same datatypes and column size
• Indexes must be defined same as index partition
– Same index type
– Based on same columns
• Create using CTAS
– Range of values must correspond to those in partition
• Locate table in "Table Data" tablespace
• Locate indexes in "Index Data" tablespace
• Gather statistics, using DBMS_STATS package
Swap Dummy Table with Partition
• Do using ALTER TABLE EXCHANGE
PARTITION command
• Object definitions must correspond exactly
or operation will fail
• Is fast; Just dictionary command
• No data moves
• Process effectively populates the partition
• Statistics swapped too
Make Tablespaces Read Only

• Backup Datafiles
• Drop dummy table
– Is now empty
Repeat Procedure
• Add Partition
– Use ALTER TABLE ADD PARTITION command
• Create two tablespaces
• Build dummy table and indexes
– Place each in tablespace
– Range must match partition
• Gather Statistics
• Swap Partitions
• Make Tablespaces Read Only
• Drop dummy table
• Continue till reaching current time period
Synchronize Tables
• Add last partition
• Create two current tablespaces
– Make locally managed
– Place on raid 1 or 0 + 1 disks.
– Size larger
• Stop all modifications to non-partitioned table
• Build final dummy table and dummy indexes
• Swap table and indexes with final partition
– Tables are effective copies of one another.
STEP 2

Cutover From
Old Table to New
Rename Old (Non-Partitioned)
Table and Indexes
• Use RENAME TO command for table
• For Indexes, use ALTER INDEX
RENAME TO command
Name New (Partitioned) Table
and Indexes Same as Old
• Use RENAME TO command
• Use ALTER INDEX RENAME TO
command
• Is critical names match, so that privileges,
stored outlines and code hints work
STEP 3

Drop Original
(Non-Partitioned) Table
STEP 4

Maintain Partitioned Table


as It Grows
Change Default Tablespaces
• Make "Current Table Data Tablespace" the
Default Tablespace for Partitioned Table
– Use ALTER TABLE MODIFY DEFAULT
ATTRIBUTES command
• Make "Current Index Data Tablespace" the
Default Tablespace for Partitioned Indexes
– Use ALTER INDEX MODIFY DEFAULT
ATTRIBUTES command
Create Desired Number
of New Partitions
• Use ALTER TABLE ADD PARTITION
command
– No TABLESPACE clause is necessary
• Make sure ranges are defined correctly
• Be certain partition for new time period
exists when Oracle attempts to write to it
Repeat Procedure, Building
Dummy Table & Indexes and
Swapping with Partition
• Make sure all writing, occurring on partition, has stopped
• Create two tablespaces (table and indexes)
• Build dummy table and dummy indexes
– Place each in tablespace
– Range must match partition
• Gather Statistics
• Swap Partitions
• Make Tablespaces Read Only
• Backup Datafiles
• Drop dummy table
SUMMARY
• Make tablespaces read only
• Reduce size of backups
• Move virtually all data in table anywhere online
• More performance
• Eliminate old data easily without consuming large
amounts of resources
• Makes offloading data, using transportable
tablespaces, to other databases convenient

You might also like