1 db storage_structures

Upload: anandgajelli

Post on 03-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 1 DB Storage_structures

    1/28

    1

    Physical Database Design

    40 6706

    Database Storage Structures

  • 8/12/2019 1 DB Storage_structures

    2/28

    2

    Learning Outcomes

    Database Architecture

    Role of the Database Administrator

    General Performance Issues

    Examine Oracles StorageStructures

  • 8/12/2019 1 DB Storage_structures

    3/28

    3

    Physical Design Activities

    Designing data structures to improveperformance

    Defining recovery policies Designing and implementing

    Concurrency Control policies

    Tuning applications (SQL statement

    tuning) Enroling users & granting them

    necessary privileges

  • 8/12/2019 1 DB Storage_structures

    4/28

    4

    Administrator vs.

    Developer The DBA is the sole authority for

    allocating system-wide resources

    (disk space usage, auditing, etc) However, there are many areas of

    overlap in responsibility between

    the DBA and Developers

  • 8/12/2019 1 DB Storage_structures

    5/28

    5

    Activity/User TypeDeveloper DBA

    Database Design

    Data Structure Definition

    Recovery Policy

    Design and Implementation of Concurrency

    Control Policies

    Application Tuning

    Enrolment of Users

    Who has Primary Responsibility foreach Activity?

  • 8/12/2019 1 DB Storage_structures

    6/28

    6

    Database Architecture

    QueryOptimiser

    Data Dictionary

    Security Manager

    Concurrency ControllerRecovery Manager

    b

  • 8/12/2019 1 DB Storage_structures

    7/28

    7

    Interactions betweenComponents

    Lets look at a typical scenario1. Query is parsed

    2. Table and column names sent by QO tothe DD

    3. DD validates names, sends a message tothe SM

    4. SM validates access rights

    5. DD now replies to QO6. QO generates a plan for execution andsends messages to CC for obtaining locks

    7. As transaction executes it writes

    information in the rollback segmentsmaintained b the Recover Mana er

  • 8/12/2019 1 DB Storage_structures

    8/28

    8

    Performance Issues

    Two main factors:1. processing time at the CPU

    2. Data retrieval time at the disk Data retrieval time >> Processing

    time

    Thus major objective is tominimise data retrieval (I/O)costs

  • 8/12/2019 1 DB Storage_structures

    9/28

    9

    Performance Issues -

    Compression Data retrieval costs minimised by

    clustering and/or compressingdata

    Compression can be achieved byreplacing large data fields by a codingscheme that takes up less space

    This will typically be used for a table

    with large-sized text fields These fields can be replaced by codes

    which reference the original textvalues in a lookup table

  • 8/12/2019 1 DB Storage_structures

    10/28

    10

    Clustering Oracles

    Solution Oracle clusters data at the physical

    level into data blocks

    Q) What happens when data (table)size > data block size?

    A)

    This is precisely what Oracle does!

  • 8/12/2019 1 DB Storage_structures

    11/28

    11

    Oracles StorageStructures-Extents

    Oracle organises data blocks that areaccessed together into a singlecontiguous unit called an extent

    Thus when creating a table you specifythe size of the extent

    When the table size exceeds the size ofthe extent, Oracle obtains another

    extent However there is no guarantee that the

    next extent is contiguous with theprevious one

  • 8/12/2019 1 DB Storage_structures

    12/28

    12

    Extents

    Oracle allows the designer tospecify the size of the first (initial)

    and subsequent (next) extents For a table that would be expected

    to grow linearly with time, the size

    of the initialand nextextentswould be the same

  • 8/12/2019 1 DB Storage_structures

    13/28

    13

    Relationships between Data Blocks,Extents and Segments

  • 8/12/2019 1 DB Storage_structures

    14/28

    14

    Oracles Storage Structures-Segments

    Segments are collections of extentsthat belong to one logical unit e.g.a table

    In general there four types ofsegments:

    1. Table

    2. Index3. Rollback (for Recovery)

    4. Temporary (to store intermediateresults, e.g. during sorting)

  • 8/12/2019 1 DB Storage_structures

    15/28

    15

    Oracles Storage Structures-

    Tablespaces Tablespace: a database is divided into

    logical storage units called tablespaces.

    Each tablespace in an ORACLE databaseis comprised of one or more operatingsystem files called data files.

    A tablespace's data files physically storethe associated database data on disk

  • 8/12/2019 1 DB Storage_structures

    16/28

    16

    Tablespaces and Datafiles

  • 8/12/2019 1 DB Storage_structures

    17/28

    1717

    Logical Structure Versus

    Physical Structure Logical structures are composed of orderly

    groupings of information that allow you to

    manipulate and access related data. Theycannot be viewed outside the database.

    Physical structures are composed of operating

    system components and have a physical nameand location.

  • 8/12/2019 1 DB Storage_structures

    18/28

    1818

    Logical Structure

    The logical structure of an Oracledatabase include

    Schema objects,

    Data blocks,

    Extents,

    Segments and

    Tablespaces

  • 8/12/2019 1 DB Storage_structures

    19/28

    1919

    Physical Database Structure

    Every database has one or morephysical datafiles. The Physical

    Structure of an Oracle databaseinclude:

    Data Files

    Redo log FilesControl Files

  • 8/12/2019 1 DB Storage_structures

    20/28

    2020

    Physical Database Structure

    Data Files: the datafiles contain all thedatabase data, and can be associated

    with only one database. Redo Log files: primary function is to

    record all changes made to data. Theinformation in a redo log file is used

    only to recover the database from asystem or media failure.

  • 8/12/2019 1 DB Storage_structures

    21/28

    2121

    Physical Database Structure

    Control File: contains entries thatspecify the physical structure of

    the database, such as:Database name

    Names and locations of datafiles and

    redo log files andTime stamp of database creation.

  • 8/12/2019 1 DB Storage_structures

    22/28

    22

    Database

    Logical Physica l

    Tablespace Data file

    OS blockOracle

    b lock

    Segment

    Extent

    Database Storage Hierarchy

  • 8/12/2019 1 DB Storage_structures

    23/28

    23

    Using Tablespaces

    Oracle uses a SYSTEM tablespaceto store internal information suchas the Data Dictionary

    User tables can also be stored inSYSTEM but this is notrecommended

    Mutiple tablespaces have theseadvantages: gives users betterperformance and flexibility

  • 8/12/2019 1 DB Storage_structures

    24/28

    24

    Advantages of MultipleTablespaces

    1. Control over space quotas for users

    2. Better control over data availability bytaking individual tablespaces online or

    offline3. Perform partial database backup or

    recovery

    4. Parallelise Queries by partitioning

    tables and allocating them to separatetablespaces

    5. Reduce contention between objectsby allocating them to separate

    tablespaces

  • 8/12/2019 1 DB Storage_structures

    25/28

    25

    Controlling Database Size

    Tablespaces can be used tocontrol database size in three

    ways:1. Adding a new tablespace

    2. Adding a new datafile to an existingtablespace

    3. Allowing datafiles to growdynamically

    Choice made by DBA depending

    on circumstances

  • 8/12/2019 1 DB Storage_structures

    26/28

    26

    Oracles Space Management

    Oracle maintains a list of free

    blocks for each tablespace When a new extent (N blocks) is

    required, Oracle uses the following

    algorithm:1. Search for N+1 contiguous blocks (N, if N N

    If M < N+5, then ALL blocks are allocated to new extent

    If M > N+5, allocate N to new extent and return remainder to

    free list

    3. If neither 1 or 2 applies, Oracle coalesces adjacent blocks

    (used) to release space and obtain more free blocks

  • 8/12/2019 1 DB Storage_structures

    27/28

    27

    References

    Modern Database Management fifth edition (Hoffer, Prescott and

    McFadden) Oracle 11g Database Concepts

    Chapters 2, 3 & 7

    Oracle 11g Administrators GuideChapter 8

  • 8/12/2019 1 DB Storage_structures

    28/28

    28

    Review Questions

    1. List the main activities involved inPhysical Database Design

    2. Distinguish between clusteringand compression

    3. How does Oracle ensure that datain tables are clustered?

    4. Identify four advantages of usingtablespaces