Professional Documents
Culture Documents
Getting to know the ins and outs of Oracle Partitioning in Oracle Database 11g
Ananth Raghavan Senior Director, Database Development
Agenda
Partitioning in a nutshell Oracle 11g .. a quite old release Whats new in 11.2.0.2? Some things less known Q&A
ORDERS
ORDERS
ORDERS
USA
EUROPE
JAN FEB
Large Table Partition
JAN FEB
Composite Partition
Difficult to Manage
Better Performance
More flexibility to match business needs
Transparent to applications
4
Arup Nanda
Senior Director Database Engineering and Operations Starwood Hotels
Partitioning is a key enabler for the performance of our system. We just could not process our data volumes without Partitioning.
Partitioning Benefits
Partitioning is
Faster
By touching and maintaining only the relevant data
Cheaper
By storing the data appropriately and most cost-effective
Flexible
By managing partitions autonomously
2003
2008
2009 5% Active
Flexible
Partition for Manageability/Availability
Order Table
(partitioned by quarter) Q405 Q106 Q206 Q306
Agenda
Partitioning in a nutshell Oracle 11g .. a quite old release Whats new in 11.2.0.2? Some things less known Q&A
10
As of 09/21/2010, inclusive
11
As of 09/21/2010, inclusive
12
Time for you to upgrade .. and for me to rehash Oracle Database 11g
As of 09/21/2010, inclusive
13
Time for you to upgrade .. and for me to rehash Oracle Database 11g
As of 09/21/2010, inclusive
14
Oracle Partitioning
Over a decade of development
Core functionality Oracle 8.0 Oracle 8i
Range partitioning Global Range indexes Hash partitioning Range-Hash partitioning List partitioning Range-List partitioning Global Hash indexes 1M partitions per table Virtual column based partitioning More composite choices REF partitioning Hash-Hash partitioning AND pruning Multi-dimensional pruning Fast partition SPLIT Local Index maintenance Fast DROP TABLE Interval partitioning Partition Advisor Incremental stats mgmt Multi-branch execution Segment creation on demand*
Performance
Static partition pruning Partition-wise joins Dynamic partition pruning
Manageability
Basic maintenance: ADD, DROP, EXCHANGE Expanded maintenance: MERGE Global index maintenance
Oracle 11g R2
15
15
Interval Partitioning
16
Interval Partitioning
Interval Partitioning
Extension to Range Partitioning Full automation for equi-sized range partitions
17
Interval Partitioning
As easy as One, Two, Three ..
CREATE TABLE sales (order_date DATE, ...) PARTITON BY RANGE (order_date) INTERVAL(NUMTOYMINTERVAL(1,'month') (PARTITION p_first VALUES LESS THAN ('01-JAN-2006');
Table SALES ... Jan 2006 Feb 2006 Mar 2006 First segment is created
Mandatory to have a defined lower bound
...
18
Composite Partitioning
EMEA
19
Composite Partitioning
20
REF Partitioning
Line Items
Back Orders
Stock Holds
Line Items
JAN
Pick Lists
Back Orders
FEB
Pick Lists
ORDERS
Back Orders
Pick Lists
Back Orders
MAR
Pick Lists
Back Orders
APR
Pick Lists
21
REF Partitioning
...
Redundant maintenance
23
24
ORDERS
ORDER_ID ORDER_DATE CUSTOMER_ID... 65920 REGION AS (SUBSTR(ORDER_ID,6,2)) -----US EU EU US US
8300-EU-97 14-FEB-2007
3886-EU-02 16-JAN-2007 2566-US-94 19-JAN-2007 3699-US-63 02-FEB-2007
39654
4529 15327 18733
ORDERS
USA
EMEA
25
Virtual Columns
Base table with all attributes Virtual (derived) column based on values of other columns No cross-table references possible
CREATE TABLE accounts (acc_no number(10) not null, acc_name varchar2(50) not null, ... acc_branch number(2) generated always as (to_number(substr(to_char(acc_no),1,2)))
12 12 12 12
26
12 12 12 12
...
32 32 32 32
27
Agenda
Partitioning in a nutshell Oracle 11g .. a quite old release Whats new in 11.2.0.2? Some things less known Q&A
28
Segment creation for partitioned tables (and indexes) is delayed until first data inserted
Support for partitioned objects beginning with 11.2.0.2
29
29
30
30
Agenda
Partitioning in a nutshell XX days of Oracle 11g .. Whats new in 11.2.0.2? Some things less known Q&A
31
32
Partition bounds
Interval partitions have lower and upper bound Range partitions only have upper bounds Lower bound derived by previous partition
Partition naming
Interval partitions cannot be named in advance Use the PARTITION FOR (<value>) clause Range partitions must be named
33
Partition merge
Multiple non-existent interval partitions are silently merged Only two adjacent range partitions can be merged at any point in time
Number of partitions
Interval partitioned tables have always one million partitions Non-existent partitions exist through INTERVAL clause No MAXVALUES clause for interval partitioning Maximum value defined through number of partitions and INTERVAL clause Range partitioning can have up to one million partitions MAXVALUES clause defines most upper partition
34
Interval versus Range Partitioning, cont. Interval partitioned table has classical range and automated interval section
Concept of a transition point
[USER|ALL|DBA]_TAB_PARTITIONS.INTERVAL
Table SALES
...
Jan 2006 Feb 2006 Mar 2006 Jan 2007
...
Oct 2009 Nov 2009
...
35
36
REF Partitioning
37
REF Partitioning
38
Unusable Indexes
Unusable index partitions are commonly used in environments with fast load requirements
Safe the time for index maintenance at data insertion Unusable index segments do not consume any space (11.2)
Partitioned indexes can be used by the optimizer even if some partitions are unusable
Prior to 11.2, static pruning and only access of usable index partitions mandatory With 11.2, intelligent rewrite of queries using UNION ALL
39
Multi-Branch Execution
Sample plan
40
Set a global index UNUSABLE right at partition creation time ALTER TABLE toto ADD PARTITION p2 VALUES LESS THAN (20) UPDATE INDEXES (i_toto (PARTITION p2 UNUSABLE));
42
43
43
AND Pruning
Example:
Star transformation with pruning predicate on both the FACT Dynamic pruning table and a dimension FROM sales s, times t Static pruning WHERE s.time_id = t.time_id .. AND t.fiscal_year in (2000,1999) AND s.time_id between TO_DATE('01-JAN-1999','DD-MON-YYYY') and TO_DATE('01-JAN-2000','DD-MON-YYYY')
44
44
AND Pruning
Sample plan
45
Summary
Partitioning in a nutshell
Proven functionality in 9th generation Experience comes with age and customer usage
46
Q&A
47
search.oracle.com
Oracle Partitioning
or
oracle.com
48
49