+ All Categories
Home > Documents > Adams - Hash Clusters Oracle

Adams - Hash Clusters Oracle

Date post: 30-May-2018
Category:
Upload: rockerabc123
View: 222 times
Download: 0 times
Share this document with a friend

of 17

Transcript
  • 8/14/2019 Adams - Hash Clusters Oracle

    1/17

    Steve [email protected]

    Unix + Oracle =

    Using Hash Clusters

  • 8/14/2019 Adams - Hash Clusters Oracle

    2/17

    Steve [email protected]

    Unix + Oracle =

    Table Directory Row Directory

    0

    1

    0

    1

    2

    3

    40

    1

    2

    Cluster Blocks

    Table directory

    partitions the row directory

    row numbers are relative to their table

    cluster keys are stored as table 0

  • 8/14/2019 Adams - Hash Clusters Oracle

    3/17

    Steve [email protected]

    Unix + Oracle =

    Cluster Key Changes

    Performed by recursive/service transactions commit independent of parent/user transaction

    improves concurrency

    Single threaded to prevent incompatible key changes

    always use ITL slot 1

    slot 1 is reserved - user transactions never use it

    wait in shared mode for TX lock if slot is busy

  • 8/14/2019 Adams - Hash Clusters Oracle

    4/17

    Steve [email protected]

    Unix + Oracle =

    Index Cluster Inserts

    Key can be inserted to block if number of keys < (data area size - 14) / SIZE

    available space > SIZE - 27

    key and data row pieces fit below PCTFREE Row inserts

    lookup key in cluster index

    insert to (last) data block if space permits try up to 3 previous blocks in the key chain

    link a freelist block into the key chain & insert

  • 8/14/2019 Adams - Hash Clusters Oracle

    5/17

    Steve [email protected]

    Unix + Oracle =

    Index Cluster Deletes

    Data row piece headers have a key index

    Keys have current & pending row counts

    both incremented on insert

    pending decremented on delete current decremented on stub cleanout

    Flushable keys

    current count was, or pending count is zero when inserting a new key, try to clean out all

    committed stubs and flush keys if possible

  • 8/14/2019 Adams - Hash Clusters Oracle

    6/17

    Steve [email protected]

    Unix + Oracle =

    Demonstration

    Flushable keys

    Key insert restrictions

  • 8/14/2019 Adams - Hash Clusters Oracle

    7/17

    Steve [email protected]

    Unix + Oracle =

    Demonstration

    Index clusters row inserts

  • 8/14/2019 Adams - Hash Clusters Oracle

    8/17

    Steve [email protected]

    Unix + Oracle =

    Cluster Key Scans

    Purpose to fetch all rows for a clustered table

    with a known cluster key value

    Buffer gets

    visit all blocks in the key chain (reverse order)

    scan row directory entries for the tableand check cluster key index forallrows

  • 8/14/2019 Adams - Hash Clusters Oracle

    9/17

    Steve [email protected]

    Unix + Oracle =

    Assessing Cluster Key Chaining

    Detection compare cluster key scan block gets

    to the cluster key scans statistic

    maybe DBA_CLUSTERS .AVG_BLOCKS_PER_KEY

    Fix

    rename existing tables and create new cluster use PL/SQL iterate over the cluster keys

    and copy all rows for each key in turn

  • 8/14/2019 Adams - Hash Clusters Oracle

    10/17

    Steve [email protected]

    Unix + Oracle =

    Hash Theory

    TBD

  • 8/14/2019 Adams - Hash Clusters Oracle

    11/17

    Steve [email protected]

    Unix + Oracle =

    Hash Clusters

    Fixed blocks formatted during cluster creation

    hash key value implied by location

    keys never flushed; blocks never freed no data row counts, or previous key rowid needed

    Chained blocks

    just like index cluster blocks key data is hash key value

  • 8/14/2019 Adams - Hash Clusters Oracle

    12/17

    Steve [email protected]

    Unix + Oracle =

    Demonstration

    Hash cluster

  • 8/14/2019 Adams - Hash Clusters Oracle

    13/17

    Steve [email protected]

    Unix + Oracle =

    Single Table Hash Clusters

    Better single row per hash key

    Reserved slots

    one row slot per key

    cluster key scans only inspect that slotiff no keys have more than one row

    otherwise scan allrow slots for table

    A flag in data layer flag byte no more than one row per key

  • 8/14/2019 Adams - Hash Clusters Oracle

    14/17

    Steve [email protected]

    Unix + Oracle =

    Demonstration

    Single table hash cluster

  • 8/14/2019 Adams - Hash Clusters Oracle

    15/17

    Steve [email protected]

    Unix + Oracle =

    Hash Functions

    Internal hash function returns 31-bit positive integer

    good distribution, but not perfect

    mod(hash value, HASHKEYS)

    HASH IS column_name

    must be integer column

    saves hash computation no false collisions

  • 8/14/2019 Adams - Hash Clusters Oracle

    16/17

    Steve [email protected]

    Unix + Oracle =

    Demonstration

    Single table hash cluster without HASH IS

  • 8/14/2019 Adams - Hash Clusters Oracle

    17/17

    Steve [email protected]

    Unix + Oracle =

    Hash Cluster Data Density

    Use SINGLE TABLE syntax if possible Otherwise

    2K tablespace block size

    no SIZE parameter HASHKEYS is number of fixed blocks needed

    primary key columns first in row

    Benefits minimize CPU cost of cluster key scans

    maximize data density - only one key per block


Recommended