So you think you know everything about Partitioning? Presenting with Hermann Bär, Director Product Management Oracle Herbert Rossgoderer, CEO ISE Informatik 1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Program Agenda Partitioning in the marketplace Things less know Partition exchange and PK/unique key constraint Something about inheritance Partitioning at work [Herbert Rossgoderer] Q&A 2 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Oracle Partitioning Over a decade of development Core functionality Performance Manageability Oracle 8.0 Range partitioning Global Range indexes Static partition pruning Basic maintenance: ADD, DROP, EXCHANGE Oracle 8i Hash partitioning Range-Hash partitioning Partition-wise joins Dynamic partition pruning Expanded maintenance: MERGE Oracle 9i List partitioning Global index maintenance Oracle 9i R2 Range-List partitioning Fast partition SPLIT Oracle 10g Global Hash indexes Local Index maintenance Oracle 10g R2 1M partitions per table Multi-dimensional pruning Fast DROP TABLE Oracle 11g Virtual column based partitioning More composite choices REF partitioning Interval partitioning Partition Advisor Incremental stats mgmt Oracle 11g R2 Hash-Hash partitioning Expanded REF partitioning AND pruning Multi-branch execution 3 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Oracle Partitioning Top 5 Partitioning methods % of adoption 10g 11g RANGE LIST HASH RANGE- LIST RANGE- HASH 4 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Program Agenda Partitioning in the marketplace Things less know Partition exchange and PK/unique key constraint Something about inheritance Partitioning at work [Herbert Rossgoderer] Q&A 5 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Unique Constraints/Primary Keys Unique constraints are enforced with unique indexes Primary key constraint adds NOT NULL to column Table can have only one primary key ( unique identifier ) Partitioned tables offer two types of indexes Local indexes Global index, both partitioned and non-partitioned 6 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Unique Constraints/Primary Keys Unique constraints are enforced with unique indexes Primary key constraint adds NOT NULL to column Table can have only one primary key ( unique identifier ) Partitioned tables offer two types of indexes Local indexes Global index, both partitioned and non-partitioned Which one to pick? Do I even have a choice? 7 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Index Partitioning GLOBAL index points to rows in any partition Index can be partitioned or not Partition maintenance affects entire index Global Non-Partitioned Index Global Partitioned Index LOCAL index is partitioned same as table Index partitioning key can be different from index key Index partitions can be maintained separately Table Partition Table Partition Local Partitioned Index 8 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Unique Constraints/Primary Keys Applicability of Local Indexes Local indexes are equi-partitioned with the table Follow autonomy concept of a table partition I only care about myself Requirement for local indexes to enforce uniqueness Partition key column(s) to be a subset of the unique key 9 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Unique Constraints/Primary Keys, cont. Applicability of Local Indexes Local indexes are equi-partitioned with the table Follow autonomy concept of a table partition I only care about myself Requirement for local indexes to enforce uniqueness Partition key column(s) to be a subset of the unique key PARTITION BY (col1), PK(col1)! PARTITION BY (col1), PK(col2)! 10 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Unique Constraints/Primary Keys, cont. Applicability of Global Indexes Global indexes do not have any relation to the partitions of a table By definition, a global index contains data from all partitions True for both partitioned and non-partitioned global indexes Global index can always be used to enforce uniqueness PARTITION BY (col1), PK(col1)! PARTITION BY (col1), PK(col2)! 11 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange A.k.a Partition Loading and Purging Remove and add data as metadata-only operation Exchange the metadata of partitions Same logical shape for both tables is mandatory pre-requirement for successful exchange Same number and data type of columns Note that column name does not matter Same constraints Same number and type of indexes Exchange Table Empty or new data Sales Table May 18 th 2011 May 19 th 2011 May 20 th 2011 May 21 st 2011 May 22 nd 2011 May 23 rd 2011 May 24 th 2011 12 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange, cont. Indexes Sales Table May 18 th 2011 May 19 th 2011 May 20 th 2011 May 21 st 2011 Any index on the exchange table is equivalent to a local partitioned index Exchange Table Empty or new data May 22 nd 2011 May 23 rd 2011 May 24 th 2011 13 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange, cont. Indexes Exchange Table Empty or new data Sales Table May 18 th 2011 May 19 th 2011 May 20 th 2011 May 21 st 2011 May 22 nd 2011 May 23 rd 2011 May 24 th 2011 Any index on the exchange table is equivalent to a local partitioned index What do I do when the PK index on the partitioned table needs global index enforcement? Remember the requirement of logical equivalence 14 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange and PK/Unique Constraint The Dilemma Global indexes only exist for a partitioned table But I need the index for the exchange table for uniqueness 15 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange and PK/Unique Constraint Not Really a Dilemma Global indexes only exist for a partitioned table But I need the index for the exchange table for uniqueness Not generically true Unique index only needed for enabled constraints Enforcement for new or modified data through index probe 16 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange and PK/Unique Constraint Not Really a Dilemma Global indexes only exist for a partitioned table But I need the index for the exchange table for uniqueness Not generically true Unique index only needed for enabled constraints Enforcement for new or modified data through index probe Disabled constraint prevents data insertion 17 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange and PK/Unique Constraint The solution The partitioned target table PK or unique constraint that is enforced by global index (partitioned or non-partitioned) The standalone table to be exchanged ( exchange table ) Equivalent disabled validated constraint And it s even documented * 18 Copyright 2011, Oracle and/or its affiliates. All rights reserved. * SQL, Reference Guide, constraint section; Data Warehousing Guide, Chapter 16
Partition Exchange and PK/Unique Constraint A simple example 19 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Partition Exchange and PK/Unique Constraint A simple example, cont. 20 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Data Placement with Partitioned Tables Each partition or sub-partition is a separate object Specify storage attributes at each individual level As placement policy for lower levels For each individual [sub]partition If storage attributes are not specified standard hierarchical inheritance kicks in Sub-part 1 Partition P1 Table Tablespace TBS1 21 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Data Placement with Partitioned Tables Special Case Interval Partitioning Interval Partitioning pre-creates all partitions All 1 million [sub]partitions exist logically Physical storage is (almost) determined as well Partition placement Inherited from table level STORE IN () clause for round-robin partition placement Subpartition placement Usage of subpartition template Needs bug fix #8304261 (included in 11.2.0.3) STORE IN clause currently is currently a no-op Tablespace TBS1 Table Partition P1 Sub-part 1 Sub-part 2 Partition P2 Sub-part 1 Sub-part 2 22 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Data Placement with Partitioned Tables Subpartition template Introduced in Oracle Database 9 Release 2 Allows predefinition of subpartitions for future partitions Stored as metadata in the data dictionary Subpartition definition for all future partitions Subpartition applied to every partition 23 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Program Agenda Partitioning in the marketplace Things less know Partition exchange and PK/unique key constraint Something about inheritance Partitioning at work [Herbert Rossgoderer] Q&A 24 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
www.ise-informatik.de Partitioning & Oracle Exadata for extreme Performance Herbert Rossgoderer October 5th, 2011, ise GmbH
About ISE Information Systems Engineering Enable extreme Performance. Founded 1991 IT and Business Consultancy for large and medium-sized companies Main focus: Oracle Core Technology à Database (RAC), Application Server (WebLogic) Oracle Exadata / Exalogic à extreme Performance Oracle Datawarehousing & Business Intelligence Oracle Exadata Migrations Performance Analysis & Optimization Employees: 60 Headquarter in Gräfenberg, Branches in München and Nürnberg (Germany) www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 26
Enable extreme Performance à Fly & Try Enable extreme Performance. First and only Exastack Testcenter in Germany directly at the Nürnberg Airport www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 27
Use case with one of the Global Top Player in Multichannel Retailing (B2C and B2B) Enable extreme Performance. About hybris Founded 1997; 160+ employees; 90+ implementation partners with over 1,000 professionals engaged with hybris 280+ customers (79 new customers in 2010) Average annual growth rate last four years > 60% Fastest-growing multichannel-commerce software company; largest in Europe Top References: www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 28
hybris uses open architecture - non database specific features can be used Enable extreme Performance. Challenge hybris is using Object/Relational Mapping Only common database functionality is used Every single row needs to be updated in a single transaction No bulk imports possible at all! Thousands of small SQL-Statements when SKU s are being deployed Suddenly heavy peaks in user access (e.g. Cyber Monday, Christmas trade, special offers ) Experienced contention now and then... www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 29
hybris uses open architecture - non database specific features can be used Enable extreme Performance. Challenge hybris is using Object/Relational Mapping Only common database functionality is used Every single row needs to be updated in a single transaction No bulk imports possible at all! Thousands of small SQL-Statements when SKU s are being deployed Suddenly heavy peaks in user access (e.g. Cyber Monday, Christmas trade, special offers ) Experienced contention now and then... THIS is the play for HASH (or LIST) Partitioning! www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 30
Partitioning At Work Fundamentals of HASH Partitioning Enable extreme Performance. Data is placed based on hash value of partition key Number of hash buckets equals number of partitions www.ise-informatik.de Key Value Hashing Function Key Value Hashing Function HASH partitioned table HASH partitioned index Copyright (C) ISE GmbH - All Rights Reserved 31
Partitioning At Work HASH partitioned table Enable extreme Performance. On RAC, high DML workload causes high cache fusion traffic Oracle calls this block pinging www.ise-informatik.de INSERT.. North INSERT.. South INSERT.. North INSERT.. South INSERT.. North INSERT.. South INSERT.. North INSERT.. South Node 1 Node 2 Copyright (C) ISE GmbH - All Rights Reserved 32
Partitioning At Work HASH partitioned table Enable extreme Performance. On RAC, high DML workload causes high cache fusion traffic Oracle calls this block pinging HASH (or LIST) partitioned table can alleviate this situation Caveat: Normally needs some kind of application partitioning or application RAC awareness www.ise-informatik.de INSERT.. North INSERT.. North INSERT.. North INSERT.. North Node 1 Node 2 INSERT.. South INSERT.. South INSERT.. South INSERT.. South Copyright (C) ISE GmbH - All Rights Reserved 33
First time hybris is running on Oracle Exadata - How to exploit extreme Performance? Enable extreme Performance. Used Hardware Reference System 2 Node RAC 11gR2 w/ 8 x86 cores & 128GB RAM each 2 x EMC CX4-120 CLARiiON FC Storage 2 x 30 disks, 146GB 15k rpm 2 x 2 Port 4Gbit FibreChannel Connection PoC System - Oracle Exadata V2 Machine 2 Compute Nodes 11gR2 w/ 8 x86 cores & 72GB RAM each 3 Exadata Storage Cells 3 x 8 x86 cores & 24GB RAM each 3 x 12 disks, 600GB 15k rpm 3 x 4 F20 Smart Flash Cache PCI Cards, 96GB 3 x 2 Infiniband QDR 40Gbit Connection www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 34
Partitioning helps to exploit Exadata s extreme performance w/o any changes in hybris code Enable extreme Performance. Results from PoC (SKU data load) Reference system 120 SKU s per second Exadata Machine (single node load) 2,500 SKU s per second à Factor 20 X faster Exadata Machine (two node load & w/o partitioning) only 1,900 SKU s per second à slower than single node load!!! Exadata Machine (two node load & w/ partitioning) 4,800 SKU s per second à Factor 40 X faster à Up to 90 MB/s Redo with ~ 1ms log file sync www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 35
Instance HASH Partitioning alleviates concurrency of heavy insert operations across multi instances Enable extreme Performance. How to (Alternative A) CREATE TABLE <table_name> ( ID NUMBER(10) NOT NULL, Cn...) PARTITION BY HASH(ID)! TABLESPACE <tablespace_name> STORAGE (... );!! CREATE UNIQUE INDEX <index_name> ON <table_name> (ID) LOCAL TABLESPACE <tablespace_name> STORAGE (... );!! INSERT INTO <table_name> (ID,...) SELECT SEQ_ID.nextval,... ;! www.ise-informatik.de HASH Partitioning creates n entry points into the table Copyright (C) ISE GmbH - All Rights Reserved 36
Instance List Partitioning avoids concurrency of heavy insert operations across multi instances Enable extreme Performance. How to (Alternative B) CREATE TABLE <table_name> ( ID NUMBER(10) NOT NULL, Cn......, INSTANCE_NUMBER NUMBER(1) DEFAULT sys_context('userenv','instance') NOT NULL) PARTITION BY LIST (INSTANCE_NUMBER)! ( PARTITION P1 VALUES(1), PARTITION P2 VALUES(2),!... PARTITION Pn VALUES(n))! TABLESPACE <tablespace_name> STORAGE (... );!! CREATE UNIQUE INDEX <index_name> ON <table_name> (ID, INSTANCE_NUMBER) LOCAL TABLESPACE <tablespace_name> STORAGE (... );!! INSERT INTO <table_name> (ID,...) SELECT SEQ_ID.nextval,... ; Sequence SEQ_ID forces ID to be unique in each partition! List Partitioning completely separates the entry points per instance www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 37
Partitioning At Work Fundamentals of HASH Partitioning Enable extreme Performance. www.ise-informatik.de HASH Partitioning is more useful than you think Oracle mostly talks about HASH Partitioning in the context of enabler for partition-wise joins HASH Partitioning enabled transparent linear scaling of application in a Real Application Cluster environment Alternative for List if you cannot provide application partitioning In addition, HASH Partitioning is specifically beneficial for indexes HASH Partitioning provides a simply an easy way to isolate and spread out work Copyright (C) ISE GmbH - All Rights Reserved 38
Partitioning At Work HASH partitioned index Enable extreme Performance. High DML workload can create hot spots (contention) on index blocks E.g. artificial (right hand growing) primary key index www.ise-informatik.de INSERT.. 1 INSERT.. 2 INSERT.. 3 INSERT.. 4 INSERT.. 5 INSERT.. 6 INSERT.. 7 INSERT.. 8 Copyright (C) ISE GmbH - All Rights Reserved 39
Partitioning At Work HASH partitioned index Enable extreme Performance. High DML workload can create hot spots (contention) on index blocks E.g. artificial (right hand growing) primary key index With HASH partitioned index you get warm spots www.ise-informatik.de INSERT.. 1 INSERT.. 2 INSERT.. 3 INSERT.. 4 INSERT.. 5 INSERT.. 6 INSERT.. 7 INSERT.. 8 INSERT.. 1 INSERT.. 3 INSERT.. 5 INSERT.. 7 INSERT.. 2 INSERT.. 4 INSERT.. 6 INSERT.. 8 Copyright (C) ISE GmbH - All Rights Reserved 40
Composite Instance List Hash Partitioning avoids concurrency on x-instance loads Enable extreme Performance. How to (enhanced alternative B) CREATE TABLE <table_name> ( ID NUMBER(10) NOT NULL, Cn......, INSTANCE_NUMBER NUMBER(1) DEFAULT sys_context('userenv','instance') NOT NULL) PARTITION BY LIST (INSTANCE_NUMBER) SUBPARTITION BY HASH (ID) SUBPARTITIONS <m> ( PARTITION P1 VALUES(1), PARTITION P2 VALUES(2),!... PARTITION Pn VALUES(n))! TABLESPACE <tablespace_name> STORAGE (... );!! CREATE UNIQUE INDEX <index_name> ON <table_name> (ID, INSTANCE_NUMBER) LOCAL TABLESPACE <tablespace_name> STORAGE (... );!! INSERT INTO <table_name> (ID,...) SELECT SEQ_ID.nextval,... ; Sequence SEQ_ID forces ID to be unique in each partition! www.ise-informatik.de Copyright (C) ISE GmbH - All Rights Reserved 41
Find the right technique to scale with heavy parallel Insert operations across instances Enable extreme Performance. Trying following techniques www.ise-informatik.de Reverse Key Indexes à Range Scans no longer available HASH Partitioned Indexes à alleviates hot spot for right hand growing index à still concurrency on table blocks and block pinging for index blocks Hash Partitioned tables w/ local indexes à much better, however still concurrency on x-instance inserts Composite List by Instance and Hash Subpartitioning w/ local indexes à optimal solution, eliminates concurrency and brings load job to scale linearly Copyright (C) ISE GmbH - All Rights Reserved 42
Summary Partitioning in the marketplace Mature and proven technology for decades Broad set o functionality Always things less known Proven in real world, as discussed by Herbert Ongoing investment in Partitioning Questions? Suggestions? hermann.baer@oracle.com 43 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
44 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Q&A
45 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
46 Copyright 2011, Oracle and/or its affiliates. All rights reserved.