Partitioning What, When, Why & How. Arup Nanda Starwood Hotels

Similar documents
Partitioning WWWH What, When, Why & How

Automating Information Lifecycle Management with

Data Warehousing & Big Data at OpenWorld for your smartphone

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

TECHNOLOGY: Security Encrypting Tablespaces

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Oracle Database 10g : Administration Workshop II (Release 2) Course 36 Contact Hours

Course Contents of ORACLE 9i

Oracle 1Z Oracle Database 10g: Administration II. Download Full Version :

Data Vault Partitioning Strategies WHITE PAPER

TestsDumps. Latest Test Dumps for IT Exam Certification

Automatic Data Optimization with Oracle Database 12c O R A C L E W H I T E P A P E R S E P T E M B E R

So you think you know everything about Partitioning?

ORACLE DBA TRAINING IN BANGALORE

1Z Upgrade Oracle9i/10g to Oracle Database 11g OCP Exam Summary Syllabus Questions

1Z Upgrade to Oracle Database 12cm Exam Summary Syllabus Questions

How To Reduce Temp Tablespace Size In Oracle 11g

Explore the Oracle 10g database architecture. Install software with the Oracle Universal Installer (OUI)

What s New with Oracle Data Pump in Oracle Database 12c. Dean Gagne Consulting Member of Technical Staff

File Structures and Indexing

Projects. Corporate Trainer s Profile. CMM (Capability Maturity Model) level Project Standard:- TECHNOLOGIES

IT Best Practices Audit TCS offers a wide range of IT Best Practices Audit content covering 15 subjects and over 2200 topics, including:

Donald K. Burleson Dave Ensor Christopher Foot Lisa Hernandez Mike Hordila Jonathan Lewis Dave Moore Arup Nanda John Weeg

Oracle 11g Partitioning new features and ILM

Oracle 11g New Features for DBAs. Arup Nanda

Tablespace Usage By Schema In Oracle 11g Rac

IT100: Oracle Administration

ENHANCING DATABASE PERFORMANCE

ORACLE 11gR2 DBA. by Mr. Akal Singh ( Oracle Certified Master ) COURSE CONTENT. INTRODUCTION to ORACLE

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Persistence Performance Tips

RAC for Beginners. Arup Nanda Longtime Oracle DBA (and a beginner, always)

Oracle 1Z0-053 Exam Questions & Answers

Oracle Database 10g Migration to Automatic Storage Management. An Oracle White Paper August 2005

Oracle Database Upgrade, Migration & Transformation Tips & Techniques Chapter 5

Manual Trigger Sql Server Updating Column In Same Table

MySQL 5.1 Past, Present and Future MySQL UC 2006 Santa Clara, CA

Replication. Some uses for replication:

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM

Exam Questions 1Z0-062

Information Lifecycle Management for Business Data. An Oracle White Paper September 2005

CHAPTER. Oracle Database 11g Architecture Options

Question No : 1 Which three statements are true regarding persistent lightweight jobs? (Choose three.)

Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Exam 1Z0-061 Oracle Database 12c: SQL Fundamentals

Tablespace Usage By Schema In Oracle 11g Query To Check Temp

1z0-043 Oracle Database 10g: Administration II

Chapter One. Concepts BACKUP CONCEPTS

Focus On: Oracle Database 11g Release 2

Oracle DBA Course Content

How to speed up a database which has gotten slow

Segregating Data Within Databases for Performance Prepared by Bill Hulsizer

Oracle Database 11g for Experienced 9i Database Administrators

Question No : 1 Which three statements are true regarding the use of the Database Migration Assistant for Unicode (DMU)?

Projects. Corporate Trainer s Profile. CMM (Capability Maturity Model) level Project Standard:- TECHNOLOGIES

Oracle Rebuild All Unusable Indexes In Schema

Oracle 9i release 1. Administration. Database Outsourcing Experts

Studio 2008 Change Table

Chapter 4 Data Movement Process

Oracle Database 10g: New Features for Administrators Release 2

An Oracle White Paper February Optimizing Storage for Oracle PeopleSoft Applications

Internals of Active Dataguard. Saibabu Devabhaktuni

10/29/2013. Program Agenda. The Database Trifecta: Simplified Management, Less Capacity, Better Performance

Things to remember when working with Oracle... (for UDB specialists)

Change Default Temporary Tablespace Use Oracle 11g Create

Automatic Informix Range Interval Partitioning and Rolling Windows to Organize your data by Lester Knutsen. Webcast on June 21, 2018 At 2:00pm EDT

Exam Prep Seminar Package: Oracle Database 12c Administrator Certified Associate

Application Containers an Introduction

Information Lifecycle Management with Oracle Database 10g Release 2 and NetApp SnapLock

OTN Case Study: Amadeus Using Data Guard for Disaster Recovery & Rolling Upgrades

Oracle. Exam Questions 1Z Oracle Database 11g: New Features for 9i OCPs. Version:Demo

Application Containers an Introduction

Recovering Oracle Databases

Get Oracle Schema Ddl Syntax With Dbms_metadata

IBM DB2 Log Analysis Tool Version 1.3

Data Warehousing 11g Essentials

Partitioning Tables and Indexing Them

Manual Trigger Sql Server 2008 Examples Insert Update Delete

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

Call: Oracle 11g DBA Course Content:35-40hours Course Outline

April 22-26, 2012 Mandalay Bay Convention Center Las Vegas, Nevada, USA. How Oracle Locking Works Session 889 Arup Nanda Longtime Oracle DBA

Multitenant Databases. Arup Nanda Longtime Oracle DBA

Oracle 11g Alter Table Move Tablespace Example

Online Operations in Oracle 12.2

Oracle Database 12c R2: New Features for Administrators Part 2 Ed 1

Sql Server 2005 Create Script To Copy Database Schema And All The Objects

Partitioning in Oracle 12 c. Bijaya K Adient

CHAPTER. Planning and Managing Tablespaces

Data Compression in Blackbaud CRM Databases

Oracle Database 12c R2: New Features for Administrators Part 2 Ed 1 -

Oracle FLEXCUBE Private Banking May 2011

What was new in 11g for Backup and Recovery? Contents

Kathleen Durant PhD Northeastern University CS Indexes

JapanCert 専門 IT 認証試験問題集提供者

Mobile : ( India )

Guide to installing Oracle 10G Enterprise Edition Server (and creating databases) on Windows, for Controller 8.2

Exam: 1Z Title : Oracle9i: Performance Tuning. Ver :

Oracle-to-Oracle Data Transfer Options. Sudhanshu Kumar 1 st Feb 2010

Incrementally Updating Backups Tips and Tricks

PostgreSQL: Decoding Partition

Transcription:

Partitioning What, When, Why & How Arup Nanda Starwood Hotels

Who am I Oracle DBA for 14 years and counting Speak at conferences, write articles, 4 books Brought up the Global Database Group at Starwood Hotels, in White Plains, NY Responsible for Architecture, Strategy and Engineering Assist in Operations 2

About this Session This is not an introduction to partitioning Will not cover syntax What type of partitioning When to use partitioning Why partition something How to use partitioning to overcome common challenges Caveats and traps to watch out for A complete case study to show how decisions are made 3

Index Blocks Too Hot to Handle Consider an index on TRANS_ID a monotonically increasing number It may make a handful of leaf blocks experience severe contention This hot area shifts as the access patterns change Solution: Reverse Key Index? 1-20 1-10 11-20 12-20 13-20 14-20 4

Hash Partitioned Index Index Can be hash-partitioned, regardless of the partitioning status of the table create index IDX_TRANS_1 on TRANS (TRANS_ID) global partition by hash (RES_ID) partitions 8 Table TRANS is un-partitioned; while index is partitioned. This creates multiple segments for the same index, forcing index blocks to be spread on many branches. Can be rebuilt: alter index IN_RES_01 rebuild partition <PartName>; Can be moved, renamed, etc. 5

When Overlap between Logical Modeling and Physical Design Logical Partition Design Physical Last part of logical design and first part of physical design When should partitioning be used In almost all the time for large tables There is no advantage in partitioning small tables, right? Wrong. In some cases small tables benefit too 6

Why? Common Reasons Easier Administration: Smaller chunks are more manageable Rebuilding indexes partition-by by-partition Data updates, does not need counters Performance: full table scans are actually partition scans Partitions can be joined to other partitions Latching 7

More Important Causes Data Purging DELETEs are expensive REDO and UNDO Partition drops are practically free Local indexes need not be rebuilt Archival Usual approach: insert into archival table select * from main table Partition exchange Local indexes need not be rebuilt 8

Materialized Views Refreshes Partition Exchange Create a temp table Create Indexes, etc. When done, issue: alter table T1 exchange partition sp11 with table tmp1; Data in TMP1 is available Temp Table sp11 sp21 sp31 sp41 sp12 sp13 partition p1 sp22 partition p2 sp32 sp33 partition p3 partition p4 Table 9

Backup Efficiency When a tablespace is read-only, it does not change and needs only one backup RMAN can skip it in backup Very useful in DW databases Reduces CPU cycles and disk space A tablespace can be read only when all partitions in them can be so SQL> alter tablespace Y08M09 read only; 10

Data Transfer Traditional Approach insert into target select * from source@dblink Transportable Tablespace Make it read only Copy the file "Plug in" the file as a new tablespace into the target database Can also be cross-platform Source TST TS1 Target TST TS1 11

Information Lifecycle Management When data is accessed less frequently, that can be moved to a slower and cheaper storage, e.g. from DMX to SATA Two options: 1. Create a tablespace ARC_TS on cheaper disks ALTER TABLE TableName MOVE PARTITION Y07M08 TABLESPACE ARC_TS; Reads will be allowed; but not writes 2. ASM Approach ALTER DISKGROUP DROP DISK ADD DISK Fully available Fast Disk TS1 Slow Disk ARC_TS 12

How to Decide First, decide on the objectives of partitioning. Multiple objectives possible Objectives Data Purging Data Archival Performance Improving Backups Data Movement Ease of Administration Different Type of Storage Assign priorities to each of these objectives 13

Global-vs-Local Index Whenever possible, use local index In Primary Key (or Unique) Indexes: If part column is a part of the PK local is possible and should be used e.g. RES table. PK (RES_DT, RES_ID) and part key is (RES_DT) If not, try to include the column in PKs E.g. if RES_ID was the PK of RES, can you make it (RES_DT, RES_ID)? Ask some hard design questions Do you really need a PK constraint in the DW? 14

Case Study Large Hotel Company Fictitious; any resemblance to real or fictional entities is purely coincidental 15

Background Hotel reservations made for future dates When guests check out, the CHECKOUTS table is populated RESERVATIONS has RES_DT is always in future (up to three years) CHECKOUTS has CK_DT is always present or past. 16

Thought Process Q: How will the tables be purged? A: Reservations are deleted 3 months after they are past. They are not deleted when cancelled. Checkouts are deleted after 18 months. A: Decision: Since the deletion strategy is based on time, Range Partitioning is the choice with one partition per month. 17

Column Since deletion is based on RES_DT and CK_DT, those columns were chosen as partitioning key for the respective tables Scripts: create table reservations ( )( partition by range (res_dt( res_dt) ) ( partition Y08M02 values less than (to_date('2008-03 03-01','yyyy-mm-dd')), partition PMAX values less than (MAXVALUE) ) 18

Access Patterns Q: Will checkouts within last 18 months be uniformly accessed? A: No. Data <= 3 months is heavily accessed. 4-99 months is light; 9+ is rarely accessed. Decision: Use Information Lifecycle Management to save storage cost. 19

Access Types Q: Is it possible that data in past months can change? A: Yes, within 3 months to make adjustments. Q: How likely that it will change? A: Infrequent; but it does happen. 3+ months: not possible to change. Q: How about Reservations? A: They can change any time for the future. Decision: Make partitions read only. 20

Partitioning 1 st Pass RESERVATIONS CHECKOUTS Part RES_ID UPD_DT RES_DT GST_ID FK Part CK_ID CK_DT UPD_DT FOLIO_ID FK GUESTS GST_ID GST_NAME Part FOLIOS FOLIO_ID FOLIO_DT RES_ID Part TRANSACTIONS FOLIO_ID TRAN_ID TRANS_DT No FOLIO_DT column 21

Column Add for Partitioning RESERVATIONS CHECKOUTS Part RES_ID UPD_DT RES_DT GST_ID FK Part CK_ID CK_DT UPD_DT FOLIO_ID FK GUESTS GST_ID GST_NAME Part FOLIOS FOLIO_ID FOLIO_DT RES_ID FOLIO_DT column was added Part TRANSACTIONS FOLIO_ID TRAN_ID TRANS_DT FOLIO_DT 22

Problem Purge on CHECKOUTS, FOLIOS and TRANSACTIONS is based on CK_DT, not FOLIO_DT FOLIO_DT is the date of creation of the record; CK_DT is updated date The difference could be months; so, purging can't be done on FOLIO_DT Solution: Partitioning Key = CK_DT Add CK_DT to other tables 23

2 nd Pass RESERVATIONS CHECKOUTS Part RES_ID UPD_DT RES_DT GST_ID FK Part CK_ID CK_DT UPD_DT FOLIO_ID FK CK_DT column was added GUESTS GST_ID GST_NAME Part FOLIO FOLIO_ID FOLIO_DT RES_ID FK CK_DT Part TRANSACTIONS FOLIO_ID FK TRAN_ID TRANS_DT CK_DT 24

Problems after 2 nd Pass #1 FOLIOS records created at Check-in CK_DT is updated at Check-out; the record may move to a different partition Decision = Acceptable #2 CK_DT will not be known at Check-in; so value will be NULL. Which partition? Decision = not NULL; set to tentative date against Relational Database Puritan Design 25

Problems, cont.. #3: TRANS table may have many rows; updating CK_DT may impact negatively Decision: Remove CK_DT from TRANS Partition on TRANS_DT Fact: TRANS_DT <= CK_DT So, when partition SEP08 of CHECKOUTS is dropped, SEP08 partition of TRANSACTIONS can be dropped too Just because part columns are different, purge does not have to different. 26

3rd Pass RESERVATIONS CHECKOUTS Part RES_ID UPD_DT RES_DT GST_ID FK Part CK_ID CK_DT UPD_DT FOLIO_ID FK CK_DT GUESTS GST_ID GST_NAME Part FOLIO FOLIO_ID FOLIO_DT RES_ID FK CK_DT Part TRANSACTIONS FOLIO_ID FK TRAN_ID TRANS_DT CK_DT column was removed 27

Scenario #1 Reservation made on Aug 31 st for Sep 30 th checking out tentatively on Oct 1st Records Created: Table Part Key UPD_DT Partition RESERVATIONS 09/30 08/31 SEP08 Guest checks in on 9/30 FOLIOS 10/01 09/30 OCT08 Checks out on Oct 2nd: CHECKOUTS 10/02 10/02 OCT08 TRANSACTIONS 10/02 10/02 OCT08 28

CK_DT in RES? New Thought: Why not partition RESERVATIONS table by CK_DT as well? CK_DT column not present in RES But can be calculated; since we know the number of days of stay. Tentative Checkout Date column added 29

4th Pass RESERVATIONS RES_ID UPD_DT PartCK_DT RES_DT GST_ID FK CK_DT column added Part CHECKOUTS CK_ID CK_DT UPD_DT FOLIO_ID FK CK_DT GUESTS GST_ID GST_NAME Part FOLIO FOLIO_ID FOLIO_DT RES_ID FK CK_DT Part TRANSACTIONS FOLIO_ID FK TRAN_ID TRANS_DT 30

Scenario #1 Modified Reservation made on Aug 31 st for Sep 30 th checking out tentatively on Oct 1st Records Created: Table Part Key UPD_DT Partition RESERVATIONS 10/01 08/31 OCT08 Guest checks in on 9/30 FOLIOS 10/01 09/30 OCT08 Checks out on Oct 2nd: CHECKOUTS 10/02 10/02 OCT08 TRANSACTIONS 10/02 10/02 OCT08 RESERVATIONS 10/02 10/02 OCT08 New record New record New record Update 31

Scenario #2 Guest checks out on Nov 1 st, instead of Oct 1 st Records Created: Table Part Key UPD_DT Partition RESERVATIONS 10/01 08/31 OCT08 Guest checks in on 9/30 FOLIOS 10/01 09/30 OCT08 Checks out on Nov 1st: CHECKOUTS 11/01 11/01 NOV08 TRANSACTIONS 11/01 11/01 NOV08 RESERVATIONS 11/01 11/01 NOV08 FOLIOS 11/01 11/01 NOV08 st : New record New record New record Row Migration Row Migration 32

New Column for Partitioning Added a column CK_DT Two Options for Populating: Apps populate it (possible since this is still in design) Apps will have to change Guaranteed logic Triggers populate (retrofitting partitioning after the apps are written) No change to apps No guarantee of logic 33

11g Reference Partitions No need to have a new column Partitions are defined on Foreign Keys, which follow the parent's partitioning scheme. One of the most useful innovations in 11g create table trans ( trans_id number not null, folio_id number not null, trans_date date not null, amt number, constraint fk_trans_01 foreign key (folio_id) references folios ) partition by reference (fk_trans_01); 34

Non-Range Cases GUESTS table is unique: 500 million+ records No purge requirement No logical grouping of data. GUEST_ID is just a meaningless number All dependent tables are accessed concurrently, e.g. GUESTS and ADDRESSES are joined by GUEST_ID No meaningful range partitions possible 35

Hash Partitions GUESTS table is hash partitioned on GUEST_ID Number of Parts: in such a way that each partition holds 2 million records Number of partitions must be a power of 2. So 256 was chosen. All dependent tables like ADDRESSES were also partitioned by hash (guest_id( guest_id) 36

Hotels Tables HOTELS table holds the names of the hotels Several dependent tables exist DESCRIPTIONS, AMENITIES, etc. all joined to HOTELS by HOTEL_ID Partitioning by LIST? 37

Hotels Table Partitioning Requirements: Very small No regular purging needs Mostly static; akin to reference data Can't be read only; since programs update them regularly. Decision: No partitioning 38

Tablespace Decisions Partitions of a table can go to Individual tablespaces The same tablespace How do you decide? Too many tablespaces too many datafiles longer checkpoints 39

Individual Tablespaces Tablespaces named in line with partitions, e.g. RES0809 holds partition Y08M09 of RESERVATION table. Easy to make the tablespace READ ONLY Easy to backup backup only once Easy to ILM Move datafiles to lower cost disks ALTER DATABASE DATAFILE '/high_cost high_cost/ ' ' RENAME TO '/low_cost low_cost/ '; 40

Combined Solution Create a tablespace for each period TS0809 for Sep '08 Contains partitions Y08M09 for all tables RESERVATIONS, CHECKOUTS, Partitions of the same period for all the tables are usually marked read only If not possible, then this approach fails 41

Final Design Current Month F2.dbf Tablespace TS0807 F1.dbf Y08M07 Y08M08 Y08M07 Tablespace TS0808 Y08M08 Y08M07 Y08M08 F1.dbf F3.dbf Y08M09 Y08M09 Y08M09 F4.dbf RESERVATIONS CHECKOUTS TRANSACTIONS F1.dbf F5.dbf F6.dbf 42

Backup READ ONLY backed up only once F2.dbf Tablespace TS0807 F1.dbf Y08M07 Y08M08 Y08M07 Tablespace TS0808 Y08M08 Y08M07 Y08M08 F1.dbf F3.dbf Y08M09 Y08M09 Y08M09 F4.dbf RESERVATIONS CHECKOUTS TRANSACTIONS Current Month F1.dbf F5.dbf F6.dbf 43

ILM slowest medium F2.dbf Tablespace TS0807 F1.dbf Y08M07 Y08M08 Y08M07 Tablespace TS0808 Y08M08 Y08M07 Y08M08 F1.dbf F3.dbf Y08M09 Y08M09 Y08M09 F4.dbf RESERVATIONS CHECKOUTS TRANSACTIONS Current Month fastest F1.dbf F5.dbf F6.dbf 44

Partitioning Tips List the objectives of partitioning, in the order of priority Try to make the same partitioning for all related tables Try to introduce new columns Avoid Global Indexes 45

Tips for Choosing Part Key Changeable columns do not automatically mean they are not good for part key If partition ranges are wide enough, row movement is less likely Row movement may not be that terrible, compared to the benefits 46

47