Tải bản đầy đủ (.ppt) (20 trang)

Using Oracle Data Storage Structures Efficiently pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (145.95 KB, 20 trang )

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
14-13
Copyright © Oracle Corporation, 2002. All rights reserved.
Hash Partitioning Overview

Easy to Implement

Enables better performance for PDML and
partition-wise joins

Inserts rows into partitions automatically based on
the hash of the partition key

Supports (hash) local indexes

Does not support (hash) global indexes
14-14

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
9 VALUES('MA','NY','CT','ME','MD'),
10 PARTITION region_west
11 VALUES('CA','AZ','NM','OR','WA'),
12 PARTITION region_south
13 VALUES('TX','KY','TN','LA','MS'),
14 PARTITION region_central
15 VALUES('OH','ND','SD','MO','IL'));
14-15
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-16

Copyright © Oracle Corporation, 2002. All rights reserved.
Composite Partitioned Table Overview

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
14-17
Copyright © Oracle Corporation, 2002. All rights reserved.
Global
Nonpartitioned index
Local partitioned index
Global Partitioned Index
Partitioned Indexes for Scalable Access
Table
partition
Table
partition
Table

partition
Table
partition
14-19
Copyright © Oracle Corporation, 2002. All rights reserved.
Partition Pruning
Partition pruning: Only the relevant
partitions are accessed.
99-May
99-Apr
99-Feb
99-Jan
99-Mar
99-Jun
sales
SQL> SELECT SUM(sales_amount)
2 FROM sales
3 WHERE sales_date BETWEEN
4 TO_DATE(‘01-MAR-1999’,
5 ‘DD-MON-YYYY’) AND
6 TO_DATE(‘31-MAY-1999’,
7 ‘DD-MON-YYYY’);
14-20
Copyright © Oracle Corporation, 2002. All rights reserved.
Nonpartition-wise join
Full partition-wise join
Partial partition-wise join
Query slave Partition
Partitioned table
1

2
3
Partition-Wise Join
14-22
Copyright © Oracle Corporation, 2002. All rights reserved.
Statistics Collection for
Partitioned Objects

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
14-23
Copyright © Oracle Corporation, 2002. All rights reserved.
CALL dbms_stats.gather_table_stats (
ownname => ‘o901’,
tabname => ‘sales’,
partname => ‘feb99’,
granularity => ‘partition’);
CALL dbms_stats.gather_index_stats (
ownname => ‘o901’,

indname => ‘isales’,
partname => ‘s1’);
Some dbms_stats Examples
14-25
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

×