Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 of 31 Title Slide Learn How To Partition In Oracle 9i Release 2 Reference Number: #31316 By Eric Yen System Consultant Quest Software.

Similar presentations


Presentation on theme: "1 of 31 Title Slide Learn How To Partition In Oracle 9i Release 2 Reference Number: #31316 By Eric Yen System Consultant Quest Software."— Presentation transcript:

1 1 of 31 Title Slide Learn How To Partition In Oracle 9i Release 2 Reference Number: #31316 By Eric Yen System Consultant Quest Software

2 2 of 31 Agenda Partitioning Defined Evolution of Partitioning in Oracle When to partition tables Range Partitioning Hash Partitioning List Partitioning Composite –Range-Hash –Range-List

3 3 of 31 Agenda Globally Partitioned Indexes Locally Partitioned Indexes Bringing It All Together Other Sources Of Information Summary Questions and Answers Short Survey... How did I do?

4 4 of 31 Partitioning Defined The concept of Divide and Conquer. Breaking down a large problem into smaller manageable pieces. Making a mountain into a mole hill. Your definition here. “Dividing Tables and Indexes into manageable pieces.”

5 5 of 31 Evolution of Partitioning in Oracle Oracle 8 Range Oracle 8i Range Hash Composite Range-Hash Oracle 9i Release 1 Range Hash List Composite Range-Hash Oracle 9i Release 2 Range Hash List * Composite Range-Hash Range-List

6 6 of 31 When to partition tables For “large” table. Tables >= 2 Gigs * Performance gain outweighs the management of partitioning. Archiving of data is on a schedule and repetitive.

7 7 of 31 Range Partitioning Often used when there is a logical range. Examples: –Dates Start Date Transaction Date Close Date Date of Payment –IDs Product ID Location ID UPC

8 8 of 31 Range Partitioning Code CREATE TABLE PARTITION_BY_RANGE (... BIRTH_MMINT NOT NULL, BIRTH_DDINT NOT NULL, BIRTH_YYYYINT NOT NULL) PARTITION BY RANGE (BIRTH_YYYY, BIRTH_MM, BIRTH_DD) (PARTITION PARTITION_01 VALUES LESS THAN (1970, 01,01) TABLESPACE TS01,... PARTITION PARTITION_N VALUES LESS THAN (MAXVALUE, MAXVALUE, MAXVALUE) TABLESPACE TS05 ) ENABLE ROW MOVEMENT; Partition Method Partition Key Partition Definition

9 9 of 31 Hash Partitioning Hashing allows for distributed data by a hash key. DBAs do not have to know the data. Distribution is handled by Oracle. Each partition can have its own tablespace.

10 10 of 31 Hash Partitioning Code CREATE TABLE PARTITION_BY_HASH (FIRST_NAMEVARCHAR2(10), MIDDLE_INITVARCHAR2(1), LAST_NAMEVARCHAR2(10), AGEINT NOT NULL) PARTITION BY HASH (AGE) (PARTITION P1_AGE TABLESPACE TS01, PARTITION P2_AGE TABLESPACE TS02, PARTITION P3_AGE TABLESPACE TS03, PARTITION P4_AGE TABLESPACE TS04) ENABLE ROW MOVEMENT; Partition Method Partition Key Partition Definition Hash Partitioning Code

11 11 of 31 List Partitioning Added in Oracle 9.1 In 9.2 the “DEFAULT” partition method was added. Allows DBAs to explicitly define what is in a partition. Example –States into a Region –Departments into a Division

12 12 of 31 List Partitioning Code CREATE TABLE PARTITION_BY_LIST (DEPTIDNUMBER, DEPTNAMEVARCHAR2(15), STATEVARCHAR2(2)) PARTITION BY LIST (STATE) (PARTITION DEPTS_IN_NORTH VALUES ('AK') TABLESPACE TS01,... PARTITION DEPTS_WITH_NO_REGION VALUES (DEFAULT) TABLESPACE TS05) ENABLE ROW MOVEMENT; Partition Method Partition Key Partition Definition List Partitioning Code

13 13 of 31 Composite Range-Hash Partition by Range Stored by a Hash algorithm DBAs can focus on both the ease of Range Partitioning and get the benefits of Hash Partitioning Logically divide the data and let Oracle determine where to store.

14 14 of 31 Composite Range-Hash Code CREATE TABLE PARTITION_BY_RANGE_HASH ( FIRST_NAMEVARCHAR2(10), MIDDLE_INITVARCHAR2(1), LAST_NAMEVARCHAR2(10), BIRTH_MMINT NOT NULL, BIRTH_DDINT NOT NULL, BIRTH_YYYYINT NOT NULL) TABLESPACE USERS Composite Range-Hash Code

15 15 of 31 PARTITION BY RANGE (BIRTH_YYYY, BIRTH_MM, BIRTH_DD) (PARTITION DOBS_IN_1971 VALUES LESS THAN (1972, 01,01),... PARTITION DOBS_IN_1975 VALUES LESS THAN (MAXVALUE, MAXVALUE, MAXVALUE)) ENABLE ROW MOVEMENT; Composite Range-Hash Code continued Partition Partition Method Partition Key Partition Definition Composite Range-Hash Code continued

16 16 of 31 Composite Range-Hash Code continued SUBPARTITION BY HASH(FIRST_NAME, MIDDLE_INIT, LAST_NAME) SUBPARTITION TEMPLATE( SUBPARTITION SP1 TABLESPACE TS01, SUBPARTITION SP2 TABLESPACE TS02, SUBPARTITION SP3 TABLESPACE TS03, SUBPARTITION SP4 TABLESPACE TS04, SUBPARTITION SP5 TABLESPACE TS05) Subpartition Method Subpartition Key Subpartition Name Composite Range-Hash Code continued

17 17 of 31 Composite Range-List Similar to Range-Hash partitioning. Subpartition is by List method. Allows for greater control by the DBAs. Proper use of Range-List must be carefully thought out.

18 18 of 31 Composite Range-List Code CREATE TABLE PARTITION_BY_RANGE_LIST ( FIRST_NAMEVARCHAR2(10), MIDDLE_INITVARCHAR2(1), LAST_NAMEVARCHAR2(10), BIRTH_MMINT NOT NULL, BIRTH_DDINT NOT NULL, BIRTH_YYYYINT NOT NULL, STATEVARCHAR2(2) NOT NULL) TABLESPACE USERS Composite Range-List Code

19 19 of 31 Composite Range-List Code continued PARTITION BY RANGE (BIRTH_YYYY, BIRTH_MM, BIRTH_DD) (PARTITION DOBS_IN_1971 VALUES LESS THAN (1972, 01,01),... PARTITION DOBS_IN_1975 VALUES LESS THAN (MAXVALUE, MAXVALUE, MAXVALUE)) ENABLE ROW MOVEMENT; Partition Partition Method Partition Key Partition Definition Composite Range-List Code continued

20 20 of 31 Composite Range-List Code continued SUBPARTITION BY LIST (STATE) SUBPARTITION TEMPLATE (SUBPARTITION IN_NORTH VALUES ('AK') TABLESPACE TS01, SUBPARTITION IN_EAST VALUES ('NY', 'NJ', 'VA', 'CT') TABLESPACE TS02,... SUBPARTITION NO_STATE VALUES (DEFAULT) TABLESPACE TS05) Subpartition Key Subpartition Name Subpartition Method Composite Range-List Code continued

21 21 of 31 Globally Partitioned Indexes Two types of Globally Partition Indexes. –Non-Partitioned –Partitioned Globally Non-Partitioned Indexes are “regular” indexes used in OLTP. Globally Partitioned Indexes are similar in syntax to Range partitioned tables.

22 22 of 31 Globally Partitioned Index Code CREATE INDEX PARTITION_BY_RANGE_GPI ON PARTITION_BY_RANGE (BIRTH_YYYY) GLOBAL PARTITION BY RANGE (BIRTH_YYYY) (PARTITION DOBS_IN_1971_OR_B4 VALUES LESS THAN (1972) TABLESPACE ITS01, PARTITION DOBS_IN_1972_GPI VALUES LESS THAN (1973) TABLESPACE ITS02,... PARTITION DOBS_IN_1975_OR_L8R VALUES LESS THAN (MAXVALUE) TABLESPACE ITS05) ; Index Method Index Partition Index Partition Globally Partitioned Index Code

23 23 of 31 Locally Partitioned Indexes Oracle manages the rebuild of LPI Extra time should be allocated for –Range-Hash –Range-List LPI can “point” to partition or subpartition level. No SUBPARTITION TEMPLATE

24 24 of 31 Locally Partitioned Index Code (LPI at Partition Level) CREATE INDEX PARTITION_BY_RANGE_HASH_LIP ON PARTITION_BY_RANGE_HASH (LAST_NAME) LOCAL ( PARTITION TABLESPACE ITS01,... PARTITION TABLESPACE ITSN); Index Method Index Partition Locally Partitioned Index Code – Partition Level

25 25 of 31 Locally Partitioned Index Code Continued (LPI at Subpartition Level) CREATE INDEX ON ( ) LOCAL (PARTITION TABLESPACE ITS0N ( SUBPARTITION TABLESPACE ITS01,... SUBPARTITION TABLESPACE ITS0N ),... Index Method Index Partition Index Subpartition Locally Partitioned Index Code – Subpartition Level

26 26 of 31 Locally Partitioned Index Code Continued (LPI at Subpartition Level) (PARTITION TABLESPACE ITS0N ( SUBPARTITION TABLESPACE ITS01,... SUBPARTITION TABLESPACE ITS0N ) ); Index Partition Index Subpartition Locally Partitioned Index Code – Subpartition Level

27 27 of 31 Bringing It All Together 5 table partition methods –Range, Hash, List, Range-Hash, Range-List 3 index partition methods –Global Non-partition, Global partition, Locally partition Guidelines –Is the table the “right” size? –How volatile is the data? –What are your maintenance considerations?

28 28 of 31 Other Sources Of Information Oracle9i Database Concepts Release 2 (9.2) Part Number A96524-01 Chapter 11 Partitioned Tables and Indexes Oracle9i Database Administrator's Guide Release 2 (9.2) Part Number A96521-01 Chapter 17 Managing Partitioned Tables and Indexes *

29 29 of 31 Summary Basics of partitioning –Definition, Evolution & When to partition Table partitioning methods –Range, Hash, List, Range-Hash, Range-List Index partitioning methods –Global Nonpartition, Global Partition, Locally Partition Wrapped It Up –Bringing it all together, Other Sources Of Information

30 30 of 31 Question and Answer Q uestion and Answer

31 31 of 31 Ending Slide Learn How To Partition In Oracle 9i Release 2 Reference Number: #31316 By Eric Yen System Consultant Quest Software


Download ppt "1 of 31 Title Slide Learn How To Partition In Oracle 9i Release 2 Reference Number: #31316 By Eric Yen System Consultant Quest Software."

Similar presentations


Ads by Google