Presentation is loading. Please wait.

Presentation is loading. Please wait.

Partitioned tables Partitions / partitioning / partitioned tables For very large tables Improve querying Easier admin Backup and recovery easier Optimiser.

Similar presentations


Presentation on theme: "Partitioned tables Partitions / partitioning / partitioned tables For very large tables Improve querying Easier admin Backup and recovery easier Optimiser."— Presentation transcript:

1 Partitioned tables Partitions / partitioning / partitioned tables For very large tables Improve querying Easier admin Backup and recovery easier Optimiser knows when partitioning used Can use in SQL also

2 Creating a PT Create table FRED ( IDnumber namevarchar2(25) agenumber constraint fred_pk primary key (ID) ) partition by range (age) (partition PART1 values less than (21) partition PART2 values less than (40) partition PART3 values less than (maxvalue)

3 Warning Specification of partition is exclusive Maxvalue is a general term to pick up anything that failed so far Works for text as well as number

4 Hash partition Only in Oracle 8i and above Uses a numerical algorithm based on partition key to determine where to place data Range partition = consecutive values together Hash = consecutive values may be in different partitions

5 What is Hash? Imagine 8GB table – split in 8 / 1 GB No intuitively clever way to split data Or obvious way is totally imbalanced –1 partition 7BG + 7 140MB –Huge variations in performance Randomise breakdown of data so objects of similar size –Select one column –Select number of partitions –Oracle does the rest!

6 Mechanics of hashing Each record is allocated into a bucket based on key value – e.g. Name = Joe Applying the hashing function to the value Joe uniquely returns the bucket number where the record is located: E.g. using prime number –divide KEY by a prime number –If text, translation into numeric value using ASCII code –use remainder of the division = address on the disk –if record already at same address - pointer to overflow area.

7 Hash partition - SQL Create table FRED ( Namevarchar2(25) primary key, Agenumber, Years abroadnumber ) Partition by hash (age) Partitions 2 Store in (Part1_fred, Part2_fred); (Not compulsory)

8 Sub-partitions Create table FRED ( Namevarchar2(25) primary key, Agenumber, Years abroadnumber ) Partition by range (years abroad) Subpartition by hash (name) Subpartitions 5 (partition Part1 values less than (1) partition Part2 values less than (3) partition Part3 values less than (6) partition Part4 values less than (MAXVALUE));

9 Indexing partitions Performance requirements may mean Partitioned tables should be indexed (separate issue) Create index FRED_NAME on FRED (name) Local Partitions (Part1, Part2, Part3, Part4) Local means create separate index for each partition of the table Alternative is to create a global index with values from different partitions Global indexes cannot be created for Hash partitions


Download ppt "Partitioned tables Partitions / partitioning / partitioned tables For very large tables Improve querying Easier admin Backup and recovery easier Optimiser."

Similar presentations


Ads by Google