Docsity

Improving Database Performance: Oracle Indexing and Access Methods, Slides of Business Management and Analysis

Partial preview of the text

Download Improving Database Performance: Oracle Indexing and Access Methods and more Slides Business Management and Analysis in PDF only on Docsity!

Issues in Database

Performance

  • Performance in Read / write are hardware issues => throw money at it
  • Performance of DB = ability of engine to locate data
  • Factors affecting speed of retrieval
    • Cache (sizing of objects)
    • Access method (table scan / indexes…)
    • Contention between processes
    • Indirect processes (roll back, archiving…)

Reading data in Oracle

1 – determine how to access block where data is

located

  • read data dictionary stored in separate part of DB
  • DD may be loaded up in cache (aka row cache ) to limit I/O activity

2 - DD indicates preferred access method for block

  • B tree index, partitioning, hash clusters etc…

3 - Search begins either in full scan or with index

until data found

Changing data

  • Oracle makes hard work of changes
    • Rollback data (immediate)
    • Log files (long term)
  • Changed blocks read and updated in buffer
  • Released to disk as buffer is cleared
  • But rollback info generate most I/O operations
  • In sensitive environments, simultaneous archiving makes it worse (ARCHIVELOG mode)

Indexing Problems

  • Super-fast indexes need updating as data is

changed => DB slows down.

  • More complex index = more complex update

mechanism = more rollback ….

  • DB physical structure degrades, so does

index (eg split blocks)

  • Performance decreases over time
  • Rebuild needed (which interferes with

operations) INDEX_STATS tells you how big the index has grown

Solution

  • To create an older version of data
    • Must apply roll back
    • find old roll back block (I/O)
    • Roll back index (I/O)
    • Find data (I/O)
    • Roll back data
    • Read old data
    • Reverse all changes (multiple I/O)
  • Significant I/O implications + buffer full of old stuff

Conclusions

  • Writers and readers DO interfere with each other
  • The mechanisms used by Oracle to bypass locking have performance side effects
  • Performance come with minimising I/O
    • i.e. with good access techniques
    • Precision of data location
    • Physical proximity of related data (cf: caching)
  • However: Techniques to reduce I/O numbers tend to reduce the speed of access!

About Btree indexes

  • Root and Branch blocks = approx 2% of index (small)
  • In frequent hit situations, both blocks loaded in Data Buffer all the time
  • Then only 2 I/O may be required:
    • One to read leaf block
    • One to read the table
  • In practice, read in index and in table may require reading several blocks -?

Creating and Using Indexes

  • Important for live access,
  • Even more for querying multiple tables
  • Value matching is costly process in RDB
    • No pointers
    • Connection purely on comparison basis only
    • One value against all values in joint field
  • If link between 2 huge tables, perf is low
  • All RDBs use some form of indexing
  • Some complexity involved as index can reduce physical I/O at the cost of logical I/O (CPU time)

Btree indexing (2)

  • Then branch layer is built:
  • If index > one block
    • Collect all first entries + block address of each leaf block
    • Write down into the first level branch block (packed)
    • If branch block is full, initiates second level of branch blocks etc….
  • Room is saved in branch blocks:
    • No forward and backward pointer in branch blocks
    • Entries are “trimmed” to the bare minimum
    • First entries are omitted
  • See figure 6.

Syntax

  • CREATE INDEX name ON table name

(field1, field2 …)

PCTFREE 50;

  • utility programmes to assess performance

of indexes – eg INDEX_STATS View

Some problems

  • Some situations cannot be addressed with

indexes

  • e.g. In a FIFO processing situation (e.g. a

queue), indexes will prove counterproductive

  • Index may grow to stupid proportions even with

small error rate (unsuccessful processing of data)

  • Every time a transaction is added or processed

(deleted) the index must change

Alternative: Bitmap indexing

  • Imagine following query in huge table

Find customers living in London, with 2 cars and 3 children occupying a 4 bed house

  • Index not useful – why?
    • Too big
    • If query changes in any way =>new index needed
    • Maintaining a set of indexes for each query would just be too costly
  • Use a bitmap (see table 6.1, 6.2 and 6.3)

Key points to remember

  • What is the key advantage of a bitmap

index?

  • What situation does it best suit?
  • Bitmaps can also be packed by Oracle

compression features

  • But size is unpredictable – why?

Example:

  • Table with 1,000,000 rows
  • Bitmap on one column that can contain one of 8 different values (e.g. city names)
  • Data is such that all same city together 125, times - Write the bitmap - Imagine what compression can be achieved
  • Data is such that cities are in random order, but same number of each - Same questions