les_10 workshop 2 oracle dba 10g

Upload: pnkj232

Post on 04-Jun-2018

240 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    1/27

    Copyright 2008, Oracle. All rights reserved.

    Managing Schema Objects

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    2/27

    10 - 2 Copyright 2008, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to

    manage schema objects and: Determine appropriate table types for your

    requirements: heap, partition, IOT, or cluster

    Perform related DBA tasks: Estimating the size of new tables

    Analyzing growth trends

    Managing optimizer statistics

    Reorganizing schema objects online

    Table Types

    Partition

    IOT

    Cluster

    DBA Tasks

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    3/27

    10 - 3 Copyright 2008, Oracle. All rights reserved.

    Table Types

    Related data from one or more tables are

    stored together.

    Clustered table

    Data (including non-key values) is sorted

    and stored in a B-tree index structure.

    Index-organized table

    (IOT)

    Data is divided into smaller, more

    manageable pieces.Partitioned table

    Data is stored as an unordered collection

    (heap).

    Ordinary (heap-

    organized) table

    DescriptionType

    Heap

    IOTPartitioned

    Clustered

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    4/27

    10 - 4 Copyright 2008, Oracle. All rights reserved.

    What Is a Partition

    and Why Use It?

    A partition is:

    A piece of a very large table or index Stored in its own segment

    Used for improved performance and manageability

    Table Types

    > Partition

    IOTCluster

    DBA Tasks

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    5/27

    10 - 5 Copyright 2008, Oracle. All rights reserved.

    Partitions

    Characteristics of partitions are:

    Same logical attributes: Same columns,constraints, and indexes

    Different physical attributes: Stored in different

    tablespaces Transparent to applications

    Several partitioning methods

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    6/27

    10 - 6 Copyright 2008, Oracle. All rights reserved.

    Creating a Partition

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    7/2710 - 7 Copyright 2008, Oracle. All rights reserved.

    Partitioning Methods

    Range partitioning: Maps rows based on logical

    ranges of columns valuesfor example, monthsin a year

    Hash partitioning: Maps rows based on the hash

    value of the partitioning key

    List partitioning: Maps rows based on a discrete

    list of values, provided by the DBA

    Range-hash partitioning: Maps rows using the

    range method, and within each range partition,creates hash subpartitions

    Range-list partitioning: Maps rows first based on a

    range of values, then based on discrete values

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    8/2710 - 8 Copyright 2008, Oracle. All rights reserved.

    Partition Maintenance

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    9/2710 - 9 Copyright 2008, Oracle. All rights reserved.

    Table accessby ROWID

    Index-Organized Tables

    Regular table access IOT access

    Non-key columns

    Key column

    Row header

    Table Types

    Partition

    > IOTCluster

    DBA Tasks

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    10/2710 - 10 Copyright 2008, Oracle. All rights reserved.

    Index-Organized Tables

    and Heap Tables

    Compared to heap tables, IOTs:

    Have faster key-based access to table data

    Do not duplicate the storage of primary key values

    Require less storage

    Use secondary indexes and logical row IDs

    Have higher availability because table

    reorganization does not invalidate secondary

    indexes

    IOTs have the following restrictions: Must have a primary key that is not DEFERRABLE

    Cannot be clustered

    Cannot use composite partitioning

    Cannot contain a column of type ROWID or LONG

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    11/27

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    12/2710 - 13 Copyright 2008, Oracle. All rights reserved.

    Clusters

    Clustered orders and

    order_itemtables

    Cluster Key

    (ORD_NO)

    101 ORD_DT CUST_CD

    05-JAN-97 R01PROD QTY

    A4102 20

    A5675 19

    W0824 10

    102 ORD_DT CUST_CD

    07-JAN-97 N45

    PROD QTYA2091 11

    G7830 20

    N9587 26

    Unclustered orders and

    order_itemtables

    ORD_NO ORD_DT CUST_CD------ ------ ------

    101 05-JAN-97 R01

    102 07-JAN-97 N45

    ORD_NO PROD QTY ...----- ------ ------

    101 A4102 20

    102 A2091 11102 G7830 20

    102 N9587 26

    101 A5675 19

    101 W0824 10

    Table Types

    Partition

    IOT

    > ClusterDBA Tasks

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    13/2710 - 14 Copyright 2008, Oracle. All rights reserved.

    Cluster Types

    Index cluster

    Sorted hash

    cluster

    Hash

    cluster

    1

    2

    3

    Hash function Hash function

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    14/2710 - 16 Copyright 2008, Oracle. All rights reserved.

    Situations Where Clusters Are Useful

    Data is retrieved in the order it

    was inserted

    Queries using equality predicate

    on key

    Predictable number of key values

    Often joined master-detail tables

    Rarely updated key

    Evenly distributed key values

    Uniform key distribution

    Sorted

    hashHashIndexCriterion

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    15/2710 - 17 Copyright 2008, Oracle. All rights reserved.

    Sorted Hash Cluster: Overview

    New data structure used to store data sorted by

    nonprimary key columns: Cluster key values are hashed.

    Rows corresponding to a particular cluster key

    value are sorted according to the sort key.

    Used to guarantee that row order is returned by

    queries without sorting data:

    Rows are returned in ascending or descending

    order for a particular cluster key value. ORDER BY clause is not mandatory to retrieve rows

    in ascending order.

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    16/2710 - 18 Copyright 2008, Oracle. All rights reserved.

    Sorted Hash Cluster: Example

    CREATE CLUSTER calls_cluster

    ( origin_number NUMBER

    , call_timestamp NUMBER SORT

    , call_duration NUMBER SORT)

    HASHKEYS 10000

    SINGLE TABLE HASH IS origin_number

    SIZE 50;

    CREATE TABLE calls

    ( origin_number NUMBER

    , call_timestamp NUMBER

    , call_duration NUMBER, other_info VARCHAR2(30))

    CLUSTER calls_cluster(

    origin_number,call_timestamp,call_duration

    );

    Cluster key

    Sort key

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    17/2710 - 19 Copyright 2008, Oracle. All rights reserved.

    Sorted Hash Cluster: Basic Architecture

    Cluster key 2

    Cluster key 1

    Cluster key n

    HASHKEYS

    SIZE

    Block chain

    starting points

    Rows sorted by

    sort key in eachblock chain

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    18/2710 - 20 Copyright 2008, Oracle. All rights reserved.

    Schema Management Tasks

    DBA tasks include:

    Estimating the size of new tables Analyzing growth trends

    Managing optimizer statistics

    Reorganizing schema objects online

    Table Types

    Partition

    IOTCluster

    > DBA Tasks

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    19/2710 - 21 Copyright 2008, Oracle. All rights reserved.

    Estimating Resource Usage

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    20/27

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    21/2710 - 23 Copyright 2008, Oracle. All rights reserved.

    Managing Optimizer Statistics

    Not analyzed 1

    23

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    22/2710 - 24 Copyright 2008, Oracle. All rights reserved.

    Reorganizing Schema Objects Online

    Modifying logical or physical structure of a

    schema object, such as a table or index Transparent to users

    Space requirements

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    23/2710 - 26 Copyright 2008, Oracle. All rights reserved.

    Reorganizing Objects:

    Impact Report

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    24/2710 - 27 Copyright 2008, Oracle. All rights reserved.

    Reorganizing Objects: Review

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    25/2710 - 28 Copyright 2008, Oracle. All rights reserved.

    Basic Steps for Manual

    Online Reorganization

    1. Verify that the table is a candidate for online

    reorganization.2. Create an interim table.

    3. Start the redefinition process.

    4. Copy dependent objects. (This automaticallycreates any triggers, indexes, grants, and

    constraints on the interim table.)

    5. Query the DBA_REDEFINITION_ERRORS view to

    check for errors.

    6. Optionally, synchronize the interim table.

    7. Complete the redefinition.

    8. Drop the interim table.

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    26/27

    10 - 29 Copyright 2008, Oracle. All rights reserved.

    Summary

    In this lesson, you should have learned how to manage

    schema objects and: Determine appropriate table types for your

    requirements

    Perform related DBA tasks:

    Estimating the size of new tables

    Analyzing growth trends

    Managing optimizer statistics

    Reorganizing schema objects online

  • 8/13/2019 les_10 workshop 2 oracle dba 10g

    27/27

    Practice Overview:

    Managing Schema Objects

    This practice covers the following topics:

    Monitoring table and index space usage Managing optimizer statistics

    Reorganizing table and index