OpenWorld 2015 Oracle Par22oning Did You Think It Couldn t Get Any Be6er?
Safe Harbor Statement The following is intended to outline our general product direc2on. It is intended for informa2on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func2onality, and should not be relied upon in making purchasing decisions. The development, release, and 2ming of any features or func2onality described for Oracle s products remains at the sole discre2on of Oracle. 3
Oracle Par22oning Already over a decade of development Core func;onality Performance Manageability Oracle 8.0 Range partitioning Local and global Range indexing 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 indexing 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 Reference partitioning Interval partitioning Partition Advisor Incremental stats mgmt Oracle 11g R2 Hash-* partitioning Expanded Reference partitioning AND pruning Multi-branch execution (aka table orexpansion) Oracle 12c R1 Interval-Reference partitioning Partition Maintenance on multiple partitions Asynchronous global index maintenance Online partition MOVE Cascading TRUNCATE and EXCHANGE Partial indexing 4
Just when you thought it couldn t get any beper it did! Copyright 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Database 12c Release 2 Expand Par22oning strategies Further focus on data management and scalability 6
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Data Management and Scalability
Mul2-Column List Par22oning Business Requirement Solu2on Provide enhanced business modeling with par22oning Op2mize database integra2on with par22oned tables in Hive data store New mul2-column list par22oning strategy Address more complex unordered lists 8
Mul2-Column List Par22oning (USA, Direct) (USA, Partners) (GERMANY, Direct) (JAPAN, Partners), (JAPAN, Web) DEFAULT Data is organized in lists of mul2ple values (mul2ple columns) Individual par22ons can contain sets of mul2ple values Func2onality of DEFAULT par22on (catch-it-all for unspecified values) Ideal for segmenta2on of dis2nct value pairs, e.g. (region, channel) 9
Mul2-Column List Par22oned Table Syntax example CREATE TABLE sales ( region VARCHAR2(50), channel VARCHAR2(50), ) PARTITION BY LIST (region, channel) ( partition p1 values ( USA, Direct ), partition p2 values ( USA, Partners ), partition p3 values ( GERMANY, Direct ), partition p44 values (( Japan, Partners ), ( Japan, Web )), partition p45 values (DEFAULT) ); 10
Some Details of Mul2-Column List Par22oning Allow specifica2on of more than one column as par22oning key Up to 16 par22on key columns Each set of par22oning keys must be unique Nota2on of one DEFAULT par22on Specifica2on of DEFAULT on a per-column level is not supported to avoid disambiguity Func2onal support Supported as both par22on and subpar22on strategy Support for heap tables Support for external tables Supported with Reference Par22oning and Auto-List 11
Mul2-Column List Par22oning What if there was a DEFAULT per column? (USA, Direct) (Germany, Direct) (USA, DEFAULT) (DEFAULT, Partners) Where do we store (USA, Partners)???? 12
Mul2-Column List Par22oning What if there was a DEFAULT per column? (USA, Direct) (Germany, Direct) (DEFAULT) Where do we store (USA, Partners)???? In the one-and-only DEFAULT par22on 13
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability
Auto-List Par22oning Business Requirement List par22oning for large number of dis2nct values is cumbersome Manual management Hash par22oning does not provide logical mapping Solu2on Simplify the maintenance of list par22oned tables by providing automa2c crea2on of par22ons for new values 15
Auto-List Par22oning BMW BMW Audi BMW Audi Mercedes Par22ons are created automa2cally as data arrives Extension to LIST par22oning Every dis2nct par22on key value will be stored in separate par22on Full func2onality of LIST par22oning is preserved 16
Details of Auto-List Par22oning Automa2cally creates new list par22ons that contain one value per par22on Mandatory requirement is at least one par22on No support for subpar22oning No no2on of default par22on System generated par22on names for auto-created par22ons Use FOR VALUES clause for determinis2c par22on iden2fica2on Can evolve list par22oning into auto-list par22oning Only requirement is having no DEFAULT par22on Protec2on of customer investment 17
Auto-List Par22oned Table Syntax example CREATE TABLE sales ( brand VARCHAR2(50), model VARCHAR2(50), ) PARTITION BY LIST (brand) AUTOMATIC ( partition p1 values ( BMW )); 18
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability Par22oned external tables
Par22oned External Tables Business Requirement External data sources become more common, especially in Big Data environment Performant processing of large external data sets desired Solu2on Provide declara2ve par22oning for external data sources Integrate with Big Data sources 20
Par22oned External Tables USA, Direct USA, Partners GERMANY, Direct JAPAN, Partners JAPAN, Direct HIVE Par;;on HIVE Par;;on HIVE Par;;on HIVE Par;;on HIVE Par;;on External tables can be par22oned, using all basic par22oning techniques Mul2-column par22oning op2mally suited for par22oned HIVE tables Par22on pruning and limited par22on maintenance Support of add par22on, drop par22on, exchange par22on 21
Details for Par22oned External Tables Basic par22oning methods supported declara2vely No Interval, auto-list, or reference par22oning BePer constraint support Not null, unique, primary key, foreign key Only in rely disable mode Goal: iden2cal data access for internal and external tables Same sta2s2cs Same query transforma2ons Same access path for same data structures Oracle Confiden2al Internal/Restricted/Highly Restricted 22
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability Par22oned external tables Enhanced online opera2ons
Enhanced Online Opera2ons Business Requirement Make data maintenance opera2ons more transparent for ongoing business ac2vi2es Solu2on Provide support for more online implementa2ons of frequently used DDL s 24
Currently Available Online DDL s Create index Add column Add constraint Drop Index Drop Constraint Alter table set unused column Alter table move par22on 11gR1 12cR1 25
Soon-To-Be Available Online DDL s Alter table move online for heap tables Alter table split par22on online Alter table modify non-par22oned table to par22oned table 12.2 26
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability Par22oned external tables Enhanced online opera2ons Conversion to par22oned table 27
Conversion to Par22oned Table Business Requirement One-click conversion to par22oned tables without business interrup2on Solu2on Create a mechanism to easily convert non-par22oned tables to par22oned tables via na2ve SQL 28
Conversion to Par22oned Table SALES SALES USA GERMANY JAPAN DEFAULT Convert nonpar22oned tables to par22oned tables with single SQL command No conversion of par22oning methods No in-place conversion Online and offline mode Indexes are maintained and can be converted as part of the opera2on Default rule set, can be overwripen 29
Conversion to Par22oned Table Syntax Example CREATE TABLE sales ( order_num NUMBER, region VARCHAR2 (10), ); ALTER TABLE sales MODIFY PARTITION BY LIST (region) (partition p1 values ( USA ), partition p2 values ( Germany ), partition p3 values ( Japan ), partition p4 values (DEFAULT)) ONLINE; 30
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability Par22oned external tables Enhanced online opera2ons Conversion to par22oned table Read only par22ons 31
Read Only Par22ons Business Requirement Solu2on Protect some data from upda2ng while allowing other data read write in the same table Expand read only func2onality from table level to par22ons and subpar22ons 32
Read Only Par22ons Q1 2015 Q2 2015 Q3 2015 Q4 2015 Read only Read only Read only Read write insert modify delete insert DML opera;ons blocked DML opera;ons allowed Par22ons and subpar22ons can be set to read only or read write Any apempt to alter data in a read only par22on will result in an error Ideal for protec2ng data from uninten2onal DML by any user or trigger 33
Read Only Par22ons CREATE TABLE orders ( order_id number, order_date DATE, ) READ WRITE PARTITION BY RANGE(order_date) ( partition q1_2015 values less than ( 2014-10-01 ) READ ONLY, partition q2_2015 values less than ( 2015-01-01 ) READ ONLY, partition q3_2015 values less than ( 2015-04-01 ), partition q4_2015 values less than ( 2015-07-01 ) ); 34
Read Only Par22ons Read only apribute guarantees data immutability SELECT <column_list> FROM <table> will always return the same data set aoer a table or [sub]par22on is set to read only Data immutability does not prevent all structural DDL for a table For example, ADD and MODIFY COLUMN are allowed and does not violate data immutability of exis2ng data Tables and [sub] par22ons can be set to read only Read only property follows standard apribute inheritance unless otherwise defined 35
Read Only Object versus Read Only Tablespace Read Only Tablespaces protect physical storage from updates DDL opera2ons that are not touching the storage are allowed E.g. ALTER TABLE SET UNUSED, DROP TABLE No guaranteed data immutability Read Only Objects protect data from updates Data immutability Does not prevent changes on storage E.g. ALTER TABLE MOVE COMPRESS, ALTER TABLE MERGE PARTITIONS 36
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability Par22oned external tables Enhanced online opera2ons Conversion to par22oned table Read only par22ons Filtered par22on maintenance opera2ons 37
Filtered Par22on Maintenance Opera2ons Business Requirement Combining data maintenance with par22on maintenance requires mul2ple steps Solu2on Enhance par22on maintenance opera2ons to include capability of data filtering 38
Filtered Par22on Maintenance Opera2ons ORDERS Q3_2015 ORDERS Q3_2015 Delete all orders older than one year, but preserve the ones that are not completely fullfilled yet and store them on a different tablespace in compressed format Combines data maintenance with par22on maintenance Change par22on shape Change par22on apributes Change par22on data 12.2 Drama2cally simplifies common data maintenance workflows Available for all online and offline par22on maintenance opera2ons 39
Details of Filtered Par22on Maintenance Opera2ons Single table filter predicate to MOVE, SPLIT and MERGE opera2ons No joins or other more complex constructs allowed Specifica2on applied to all affected par22ons Specifica2on will be added to the recursively generated CTAS command for the crea2on of the various new par22on or subpar22ons segments Filter predicates work for both offline and online par22on maintenance opera2ons 40
Filtered Par22on Maintenance Opera2ons Move Par;;on Syntax Example ALTER TABLE orders MOVE PARTITION q3_2015 TABLESPACE archive INCLUDING ROWS WHERE order_state = open ; 41
Par22oning Enhancements in Oracle Database 12c Release 2 Expand Par;;oning strategies Mul2-column list par22oning Auto-list par22oning Data Management and Scalability Par22oned external tables Enhanced online opera2ons Conversion to par22oned table Read only par22ons Filtered par22on maintenance opera2ons Create Table for Exchange * Reduced Cursor Invalida2ons for DDLs * 42
Oracle Par22oning in Oracle Database 12.2 Over a decade of development and be6er than ever before Oracle 8.0 Oracle 8i Core func;onality Performance Manageability Range partitioning Local and global Range indexing Hash partitioning Range-Hash partitioning Static partition pruning Partition-wise joins Dynamic partition pruning Basic maintenance: ADD, DROP, EXCHANGE Expanded maintenance: MERGE Oracle 9i List partitioning Global index maintenance Oracle 9i R2 Range-List partitioning Fast partition SPLIT Oracle 10g Global Hash indexing Local Index maintenance Oracle 10g R2 1M partitions per table Multi-dimensional pruning Fast DROP TABLE Oracle 11g Oracle 11g R2 Virtual column based partitioning More composite choices Reference partitioning Hash-* partitioning Expanded Reference partitioning AND pruning Oracle 12c R1 Interval-Reference partitioning Partition Maintenance on multiple partitions Asynchronous global index maintenance Oracle 12c R2 Auto-list partitioning Multi-column list [sub]partitioning Partitioned external tables Online partition maintenance operations Online table conversion to partitioned table Reduced cursor invalidations for DDL s Interval partitioning Partition Advisor Incremental stats mgmt Multi-branch execution (aka table orexpansion) Online partition MOVE Cascading TRUNCATE Partial indexing Filtered partition maintenance operations Read only partitions Create table for exchange 43
Summary Par22oning con2nues to get be6er & be6er across the board! Par22oning further aligns with any business requirement Oracle wants to hear from you! Interes2ng use cases and implementa2ons Enhancement requests Complaints Hermann.Baer@oracle.com 44
Safe Harbor Statement The preceding is intended to outline our general product direc2on. It is intended for informa2on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func2onality, and should not be relied upon in making purchasing decisions. The development, release, and 2ming of any features or func2onality described for Oracle s products remains at the sole discre2on of Oracle. 45