14 Copyright © Oracle Corporation, 2002. All rights reserved. Using Oracle Data Storage Structures Efficiently 14-2 Copyright © Oracle Corporation, 2002. All rights reserved. Objectives After completing this lesson, you should be able to do the following: • Compare and evaluate the different storage structures • Examine different data access methods • Implement different partitioning methods 14-3 Copyright © Oracle Corporation, 2002. All rights reserved. Data Storage Structures Cluster Index- organized table Heap table Organization by value Heap SortedClustered Partitioned table 14-4 Copyright © Oracle Corporation, 2002. All rights reserved. Selecting the Physical Structure Factors affecting the selection: • Rows read in groups • SELECT or DML statements • Table size • Row size, row group, and block size • Small or large transactions • Using parallel queries to load or for SELECT statements 14-6 Copyright © Oracle Corporation, 2002. All rights reserved. Data Access Methods To enhance performance, you can use the following data access methods: • Clusters • Indexes • B-tree (normal or reverse key) • Bitmap • Function based • Index-organized tables • Materialized views 14-7 Copyright © Oracle Corporation, 2002. All rights reserved. Clusters Clustered orders and order_item tables Cluster Key (ORD_NO) 101 ORD_DT CUST_CD 05-JAN-97 R01 PROD QTY A4102 20 A5675 19 W0824 10 102 ORD_DT CUST_CD 07-JAN-97 N45 PROD QTY A2091 11 G7830 20 N9587 26 Unclustered orders and order_item tables ORD_NO PROD QTY 101 A4102 20 102 A2091 11 102 G7830 20 102 N9587 26 101 A5675 19 101 W0824 10 ORD_NO ORD_DT CUST_CD 101 05-JAN-97 R01 102 07-JAN-97 N45 14-8 Copyright © Oracle Corporation, 2002. All rights reserved. Cluster Types Index cluster Hash cluster Hash function 14-9 Copyright © Oracle Corporation, 2002. All rights reserved. Situations Where Clusters Are Useful Criterion Uniform key distribution Evenly distributed key values Rarely updated key Often joined master-detail tables Predictable number of key values Queries using equality predicate on key Hash X X X X X Index X X X 14-10 Copyright © Oracle Corporation, 2002. All rights reserved. Partitioning Methods The following partitioning methods are available: • Range • Hash • List • Composite Range partitioning Hash partitioning Composite partitioning List partitioning 14-12 Copyright © Oracle Corporation, 2002. All rights reserved. 1 2 3 CREATE TABLE sales (acct_no NUMBER(5), person VARCHAR2(30), sales_amount NUMBER(8), week_no NUMBER(2)) PARTITION BY RANGE (week_no) (PARTITION P1 VALUES LESS THAN (4) TABLESPACE data0, PARTITION P2 VALUES LESS THAN (8) TABLESPACE data1, … PARTITION P13 VALUES LESS THAN (53)TABLESPACE data12 ); The partition key is week_no. VALUES LESS THAN must be specified as a literal. Physical attributes can be set per partition. 1 2 3 Range Partitioning Example [...]... ‘o901’, indname => ‘isales’, partname => ‘s1’); 14-23 Copyright © Oracle Corporation, 2002 All rights reserved Summary In this lesson, you should have learned how to do the following: • Compare and evaluate the different storage structures • Examine different data access methods • Implement different partitioning methods 14-25 Copyright © Oracle Corporation, 2002 All rights reserved ... Overview • • • • • • 14-16 Ideal for both historical data and data placement Provides high availability and manageability, like range partitioning Improves performance for parallel DML and supports partition-wise joins Allows more granular partition elimination Supports composite local indexes Does not support composite global indexes Copyright © Oracle Corporation, 2002 All rights reserved Partitioned... the hash of the partition key Supports (hash) local indexes Does not support (hash) global indexes Copyright © Oracle Corporation, 2002 All rights reserved List Partitioning Example SQL> CREATE TABLE locations 2 (location_id, street_address, 3 postal_code, city, state_province, 4 country_id) 5 STORAGE( INITIAL 10K NEXT 20K) 6 TABLESPACE users 7 PARTITION BY LIST (state_province) 8 (PARTITION region_east... partitioned index 14-17 Copyright © Oracle Corporation, 2002 All rights reserved Partition Pruning 99-Jan 99-Feb 99-Mar 99-Apr 99-May 99-Jun Partition pruning: Only the relevant partitions are accessed SQL> 2 3 4 5 6 7 SELECT SUM(sales_amount) FROM sales WHERE sales_date BETWEEN TO_DATE(‘01-MAR-1999’, ‘DD-MON-YYYY’) AND TO_DATE(‘31-MAY-1999’, ‘DD-MON-YYYY’); sales 14-19 Copyright © Oracle Corporation, 2002 All... Copyright © Oracle Corporation, 2002 All rights reserved Statistics Collection for Partitioned Objects • • • • 14-22 You can gather object-, partition-, or subpartition level statistics There are GLOBAL or NON-GLOBAL statistics The dbms_stats package can gather global statistics at any level for tables only It is not possible to gather: – Global histograms – Global statistics for indexes Copyright © Oracle. .. VALUES('OH','ND','SD','MO','IL')); 14-14 Copyright © Oracle Corporation, 2002 All rights reserved Default Partition for List Partitioning Create a DEFAULT list partition for all values not covered by other partitions: CREATE TABLE customer PARTITION BY LIST (state) (PARTITION p1 VALUES ('CA','CO'), PARTITION p2 VALUES ('FL','TX'), PARTITION p3 VALUES (DEFAULT) ); 14-15 Copyright © Oracle Corporation, 2002 All rights . 14 Copyright © Oracle Corporation, 2002. All rights reserved. Using Oracle Data Storage Structures Efficiently 14-2 Copyright © Oracle Corporation,. evaluate the different storage structures • Examine different data access methods • Implement different partitioning methods 14-3 Copyright © Oracle Corporation,