Oracle® Database
VLDB and Partitioning Guide 11g Release 2 (11.2)
E25523-01
September 2011
Oracle Database VLDB and Partitioning Guide, 11g Release 2 (11.2) E25523-01 Copyright © 2008, 2011, Oracle and/or its affiliates. All rights reserved. Contributors: Hermann Baer, Eric Belden, Jean-Pierre Dijcks, Steve Fogel, Lilian Hobbs, Paul Lane, Sue K. Lee, Diana Lorentz, Valarie Moore, Tony Morales, Mark Van de Wiel
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle America, Inc., 500 Oracle Parkway, Redwood City, CA 94065.
This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.
Contents
Preface............................................................................................................................................................... xv
Audience..................................................................................................................................................... xv Documentation Accessibility................................................................................................................... xv Related Documents ................................................................................................................................... xvi Conventions ............................................................................................................................................... xvi
What's New in Oracle Database to Support Very Large Databases?........................ xvii
Oracle Database 11g Release 2 (11.2.0.2) New Features to Support Very Large Databases.......... xvii
1 Introduction to Very Large Databases
Introduction to Partitioning ................................................................................................................... 1-1 VLDB and Partitioning ........................................................................................................................... 1-2
Partitioning As the Foundation for Information Lifecycle Management..................................... 1-3
Partitioning for Every Database ............................................................................................................ 1-3
2 Partitioning Concepts
Overview of Partitioning........................................................................................................................ 2-1
Basics of Partitioning ......................................................................................................................... 2-1 Partitioning Key ................................................................................................................................. 2-2 Partitioned Tables .............................................................................................................................. 2-2
When to Partition a Table .......................................................................................................... 2-3 When to Partition an Index........................................................................................................ 2-3
Partitioned Index-Organized Tables ............................................................................................... 2-3 System Partitioning............................................................................................................................ 2-3 Partitioning for Information Lifecycle Management.................................................................... 2-4 Partitioning and LOB Data ............................................................................................................... 2-4 Collections in XMLType and Object Data ...................................................................................... 2-4
Benefits of Partitioning........................................................................................................................... 2-5
Partitioning for Performance............................................................................................................ 2-5
Partition Pruning......................................................................................................................... 2-5 Partition-Wise Joins .................................................................................................................... 2-5
Partitioning for Manageability......................................................................................................... 2-6 Partitioning for Availability ............................................................................................................. 2-6
Partitioning Strategies............................................................................................................................. 2-6
Single-Level Partitioning................................................................................................................... 2-7
iii
Range Partitioning ...................................................................................................................... 2-7 Hash Partitioning........................................................................................................................ 2-8 List Partitioning........................................................................................................................... 2-8
Composite Partitioning ..................................................................................................................... 2-8
Composite Range-Range Partitioning ..................................................................................... 2-9 Composite Range-Hash Partitioning ....................................................................................... 2-9 Composite Range-List Partitioning.......................................................................................... 2-9 Composite List-Range Partitioning.......................................................................................... 2-9 Composite List-Hash Partitioning............................................................................................ 2-9 Composite List-List Partitioning............................................................................................... 2-9
Partitioning Extensions........................................................................................................................... 2-9
Manageability Extensions................................................................................................................. 2-9
Interval Partitioning ................................................................................................................ 2-10 Partition Advisor...................................................................................................................... 2-10
Partitioning Key Extensions .......................................................................................................... 2-10
Reference Partitioning............................................................................................................. 2-10 Virtual Column-Based Partitioning....................................................................................... 2-12
Overview of Partitioned Indexes ....................................................................................................... 2-12
Deciding on the Type of Partitioned Index to Use..................................................................... 2-12 Local Partitioned Indexes............................................................................................................... 2-13 Global Partitioned Indexes ............................................................................................................ 2-13
Global Range Partitioned Indexes......................................................................................... 2-14 Global Hash Partitioned Indexes........................................................................................... 2-14 Maintenance of Global Partitioned Indexes......................................................................... 2-14
Global Nonpartitioned Indexes..................................................................................................... 2-15 Miscellaneous Information about Creating Indexes on Partitioned Tables ........................... 2-15 Partitioned Indexes on Composite Partitions ............................................................................. 2-15
3 Partitioning for Availability, Manageability, and Performance
Partition Pruning...................................................................................................................................... 3-1
Benefits of Partition Pruning ............................................................................................................ 3-1 Information That Can Be Used for Partition Pruning................................................................... 3-2 How to Identify Whether Partition Pruning Has Been Used ...................................................... 3-3 Static Partition Pruning ..................................................................................................................... 3-3 Dynamic Partition Pruning............................................................................................................... 3-4
Dynamic Pruning with Bind Variables.................................................................................... 3-4 Dynamic Pruning with Subqueries .......................................................................................... 3-5 Dynamic Pruning with Star Transformation .......................................................................... 3-5 Dynamic Pruning with Nested Loop Joins ............................................................................. 3-6
Partition Pruning Tips....................................................................................................................... 3-7
Data Type Conversions.............................................................................................................. 3-7 Function Calls.............................................................................................................................. 3-9 Collection Tables...................................................................................................................... 3-10
Partition-Wise Joins .............................................................................................................................. 3-11
Full Partition-Wise Joins ................................................................................................................ 3-11
Full Partition-Wise Joins: Single-Level - Single-Level........................................................ 3-12 Full Partition-Wise Joins: Composite - Single-Level........................................................... 3-14
iv
Full Partition-Wise Joins: Composite - Composite ............................................................. 3-16
Partial Partition-Wise Joins............................................................................................................ 3-16
Partial Partition-Wise Joins: Single-Level Partitioning ...................................................... 3-17 Partial Partition-Wise Joins: Composite ............................................................................... 3-19
Index Partitioning ................................................................................................................................. 3-20
Local Partitioned Indexes............................................................................................................... 3-20
Local Prefixed Indexes ............................................................................................................ 3-21 Local Nonprefixed Indexes..................................................................................................... 3-22
Global Partitioned Indexes ............................................................................................................ 3-22
Prefixed and Nonprefixed Global Partitioned Indexes...................................................... 3-23 Management of Global Partitioned Indexes ........................................................................ 3-23
Summary of Partitioned Index Types .......................................................................................... 3-24 The Importance of Nonprefixed Indexes..................................................................................... 3-24 Performance Implications of Prefixed and Nonprefixed Indexes............................................ 3-25 Guidelines for Partitioning Indexes ............................................................................................. 3-25 Physical Attributes of Index Partitions ........................................................................................ 3-26
Partitioning and Table Compression................................................................................................. 3-27
Table Compression and Bitmap Indexes..................................................................................... 3-28 Example of Table Compression and Partitioning ...................................................................... 3-28
Recommendations for Choosing a Partitioning Strategy.............................................................. 3-29
When to Use Range or Interval Partitioning............................................................................... 3-29 When to Use Hash Partitioning .................................................................................................... 3-31 When to Use List Partitioning ....................................................................................................... 3-32 When to Use Composite Partitioning........................................................................................... 3-32
When to Use Composite Range-Hash Partitioning ............................................................ 3-33 When to Use Composite Range-List Partitioning ............................................................... 3-34 When to Use Composite Range-Range Partitioning........................................................... 3-34 When to Use Composite List-Hash Partitioning................................................................. 3-35 When to Use Composite List-List Partitioning.................................................................... 3-36 When to Use Composite List-Range Partitioning ............................................................... 3-37
When to Use Interval Partitioning................................................................................................ 3-38 When to Use Reference Partitioning ............................................................................................ 3-38 When to Partition on Virtual Columns........................................................................................ 3-39 Considerations When Using Read-Only Tablespaces ............................................................... 3-39
4 Partition Administration
Creating Partitions ................................................................................................................................... 4-1
Creating Range-Partitioned Tables and Global Indexes .............................................................. 4-2
Creating a Range-Partitioned Table......................................................................................... 4-2 Creating a Range-Partitioned Global Index............................................................................ 4-3
Creating Interval-Partitioned Tables............................................................................................... 4-4 Creating Hash-Partitioned Tables and Global Indexes ................................................................ 4-5
Creating a Hash Partitioned Table ........................................................................................... 4-5 Creating a Hash-Partitioned Global Index.............................................................................. 4-6
Creating List-Partitioned Tables ...................................................................................................... 4-6 Creating Reference-Partitioned Tables ........................................................................................... 4-8 Creating Composite Partitioned Tables.......................................................................................... 4-9
v
Creating Composite Range-Hash Partitioned Tables............................................................ 4-9 Creating Composite Range-List Partitioned Tables............................................................ 4-10 Creating Composite Range-Range Partitioned Tables....................................................... 4-12 Creating Composite List-* Partitioned Tables ..................................................................... 4-14 Creating Composite Interval-* Partitioned Tables.............................................................. 4-17
Using Subpartition Templates to Describe Composite Partitioned Tables ............................ 4-19
Specifying a Subpartition Template for a *-Hash Partitioned Table ................................ 4-19 Specifying a Subpartition Template for a *-List Partitioned Table................................... 4-20
Using Multicolumn Partitioning Keys......................................................................................... 4-21 Using Virtual Column-Based Partitioning .................................................................................. 4-24 Using Table Compression with Partitioned Tables.................................................................... 4-24 Using Key Compression with Partitioned Indexes.................................................................... 4-25 Using Partitioning with Segments................................................................................................ 4-25
Deferred Segment Creation for Partitioning........................................................................ 4-25 Truncating Segments That Are Empty ................................................................................. 4-26 Maintenance Procedures for Segment Creation on Demand ............................................ 4-26
Creating Partitioned Index-Organized Tables............................................................................ 4-26
Creating Range-Partitioned Index-Organized Tables ........................................................ 4-27 Creating Hash-Partitioned Index-Organized Tables.......................................................... 4-28 Creating List-Partitioned Index-Organized Tables............................................................. 4-28
Partitioning Restrictions for Multiple Block Sizes...................................................................... 4-29 Partitioning of Collections in XMLType and Objects ................................................................ 4-29
Performing PMOs on Partitions that Contain Collection Tables...................................... 4-30
Maintaining Partitions ......................................................................................................................... 4-31
Maintenance Operations on Partitions That Can Be Performed.............................................. 4-32 Updating Indexes Automatically.................................................................................................. 4-34 Adding Partitions............................................................................................................................ 4-36
Adding a Partition to a Range-Partitioned Table................................................................ 4-36 Adding a Partition to a Hash-Partitioned Table.................................................................. 4-36 Adding a Partition to a List-Partitioned Table .................................................................... 4-37 Adding a Partition to an Interval-Partitioned Table........................................................... 4-37 Adding Partitions to a Composite *-Hash Partitioned Table ............................................ 4-38 Adding Partitions to a Composite *-List Partitioned Table............................................... 4-38 Adding Partitions to a Composite *-Range Partitioned Table .......................................... 4-39 Adding a Partition or Subpartition to a Reference-Partitioned Table.............................. 4-40 Adding Index Partitions.......................................................................................................... 4-40
Coalescing Partitions ...................................................................................................................... 4-41
Coalescing a Partition in a Hash-Partitioned Table............................................................ 4-41 Coalescing a Subpartition in a *-Hash Partitioned Table................................................... 4-41 Coalescing Hash-Partitioned Global Indexes ...................................................................... 4-42
Dropping Partitions ........................................................................................................................ 4-42
Dropping Table Partitions ...................................................................................................... 4-42 Dropping Interval Partitions.................................................................................................. 4-44 Dropping Index Partitions...................................................................................................... 4-44
Exchanging Partitions..................................................................................................................... 4-45
Exchanging a Range, Hash, or List Partition ....................................................................... 4-45 Exchanging a Partition of an Interval Partitioned Table.................................................... 4-46