38
Chap 5. Disk IO Distribution Chap 5. Disk IO Distribution Chap 6. Index Architecture Chap 6. Index Architecture Written by Yong-soon Kwon Summerized By Sungchan Park @ IDS Lab. 2008-07-11

Chap 5. Disk IO Distribution Chap 6. Index Architecture

  • Upload
    danae

  • View
    38

  • Download
    0

Embed Size (px)

DESCRIPTION

Chap 5. Disk IO Distribution Chap 6. Index Architecture. Written by Yong-soon Kwon Summerized By Sungchan Park @ IDS Lab. 2008-07-11. Overview. Chap 5. Disk IO Distribution Oracle Storage Architecture Tuning by Disk IO Distribution Chap 6. Index Architecture Introduction to Index - PowerPoint PPT Presentation

Citation preview

Page 1: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Chap 5. Disk IO DistributionChap 5. Disk IO DistributionChap 6. Index ArchitectureChap 6. Index Architecture

Written by Yong-soon Kwon

Summerized By Sungchan Park @ IDS Lab.

2008-07-11

Page 2: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

OverviewOverview

Chap 5. Disk IO Distribution

Oracle Storage Architecture

Tuning by Disk IO Distribution

Chap 6. Index Architecture

Introduction to Index

– B+-Tree Index

– Bitmap Index

– Reverse Key Index

– Function Base Index

Random Access Tuning

Center for E-Business Technology

Page 3: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Chap 5. Disk IO DistributionChap 5. Disk IO Distribution

Page 4: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Disk IO DistributionDisk IO Distribution

Pros

Improving Performance

Cons

Probability of error increase

– Problem on one disk affects whole table

Hard to manage

Center for E-Business Technology

Page 5: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Disk IO Distribution RuleDisk IO Distribution Rule

Disk IO Distribution Rule

We should increase the probability that all disks are accessed.

– Data in each table should be distributed to all disks

How to satisfy the rule?

1. Optimizing Disk Organization

2. Segment Extent Striping

3. Applying Table Archtecture

– Partition table, IOT table

Center for E-Business Technology

Page 6: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Optimizing Disk Organization: Volume GroupOptimizing Disk Organization: Volume Group

Volume Groups(VG)

Groups of Physical Disks

One physical disk cannot belong to multiple VG

Checking VG(HP UX)

“vgdisplay –v vg01”

Important Info

“Cur PV : 4” : This VG consists of four physical disks

“Act PV : 4” : Four physical disks are active in this VG

Center for E-Business Technology

Page 7: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Optimizing Disk Organization: Logical VolumeOptimizing Disk Organization: Logical Volume

Concept of Logical Volume

Space for file system in VG

Logical Volume Usage

File System

Raw Device

Center for E-Business Technology

Page 8: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Optimizing Disk Organization: Logical Volume Optimizing Disk Organization: Logical Volume StripingStriping

Logical Volume Striping

Center for E-Business Technology

Page 9: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Optimizing Disk Organization: Logical Volume Optimizing Disk Organization: Logical Volume StripingStriping

Good Point of Logical Volume Striping

Achieve Disk IO distribution rule for each VG

Checking Logical Volume

“ldisplay –v /dev/vg01/lvol1”

Important Info

“Stripes 4” : This logical volume is striped with 4 disks

“Stripe Size(Kbytes) 64” : The striping size is 64KB

Center for E-Business Technology

Page 10: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Oracle Storage ArchitectureOracle Storage Architecture

Center for E-Business Technology

Page 11: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Oracle Storage ArchitectureOracle Storage Architecture

OS Block OS Level IO unit

DB Block n OS Block. DB IO unit

Extent Contiguous DB Blocks. Building unit of Segment

Segment Group of Extents(table, index)

Tablespace Group of Segments

Database Group of Tablespaces

Datafile Stores Segments. n Datafile make one Tablespace

Center for E-Business Technology

Page 12: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Segment Extent Striping: Create TablespaceSegment Extent Striping: Create Tablespace

Center for E-Business Technology

Page 13: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Segment Extent Striping: Create Table on Segment Extent Striping: Create Table on TablespaceTablespace

Center for E-Business Technology

Page 14: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Segment Extent Striping: Create Table on Segment Extent Striping: Create Table on TablespaceTablespace

Center for E-Business Technology

Page 15: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Segment Extent StripingSegment Extent Striping

Good Points

Storing data evenly over all disks for all tables

Disk IO distribution rule optimization

Checking Exntent Striping

Center for E-Business Technology

Page 16: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Partition TablePartition Table

Example

Data about 20~30 year old people is frequently accessed

If we just store all data in a table, there can be some disks which do not contain any data about 20~30s

– Data are not properly distributed!

Partition table

Create partition w.r.t. age!

Center for E-Business Technology

Page 17: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Partition Table: ExamplePartition Table: Example

Center for E-Business Technology

Result

Data about 20~30s are distributed to all 96 disks!

Page 18: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Wrong IO Distrubution #1Wrong IO Distrubution #1

Center for E-Business Technology

Page 19: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Wrong IO Distribution #2Wrong IO Distribution #2

Incrementally adding datafile to tablespace

Center for E-Business Technology

Page 20: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Chap 6. Index ArchitectureChap 6. Index Architecture

Page 21: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Pros. and Cons. ofPros. and Cons. of IndexingIndexing

Pros.

Improving Retrieving Performance

Cons.

Degrading Data Manipulation Performance

– Insert, Delete, …

Storage

Center for E-Business Technology

Page 22: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

ROWIDROWID

ROWID

ID given to all rows in database

Center for E-Business Technology

Page 23: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Example of ROWIDExample of ROWID

Center for E-Business Technology

Page 24: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Usage of ROWIDUsage of ROWID

Index Creation

Data Access

SQL Tuning

Center for E-Business Technology

Page 25: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

IndexIndex

B+-Tree Index

Bitmap Index

Reverse Key Index

Function Based Index

Center for E-Business Technology

Page 26: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

B+-Tree IndexB+-Tree Index

B+-Tree Index

Support efficient search, delete, and insert

Center for E-Business Technology

Page 27: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

B+-Tree Index AccessB+-Tree Index Access

Center for E-Business Technology

Page 28: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

B+-Tree Index: Pros. and Cons.B+-Tree Index: Pros. and Cons.

Pros.

Balanced

Range scan using linked list

Good for OLTP small number row access

Cons.

Bad for column with low cardinality

– Index scanning 3%~5%of Table row: Worse than table full scan

Possibility of full scan on OR operation

Center for E-Business Technology

Page 29: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Bitmap IndexBitmap Index

Bitmap Index

Good for column with low cardinality

Center for E-Business Technology

Page 30: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Bitmap Index structureBitmap Index structure

Center for E-Business Technology

Page 31: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Bitmap Index: Pros. and Cons.Bitmap Index: Pros. and Cons.

Pros.

Small space

Good for column with low cardinality

Cons.

Bad for table with frequent DML

– Bitmap is need to be decompressed before DML operation

– Need block level lock

Bad for column with high cardinality

Center for E-Business Technology

Page 32: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Reversed Key IndexReversed Key Index

Reversed Key Index

B+-Tree is bad for sequentially increasing index key column

– All insert operation need to access left block

– Competetion for left block occur!

Reversed Key Index using reversed key to avoid above situation

Center for E-Business Technology

Page 33: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Reversed Key Index: Pros. and Cons.Reversed Key Index: Pros. and Cons.

Pros.

Avoid competetion on left block

Cons.

Range scan is impossible

Center for E-Business Technology

Page 34: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Function Based IndexFunction Based Index

Function Based Index

Index for transformed value

Example

– SELECT employee_id, ceil(salary/12)*(grade-5)

FROM emp

WHERE mod(grade, 10)*1.2 > 10

Creating Function Based Index

– SQL> CREATE INDEX bonus_index on emp(mod(grade, 10)*1.2);

Center for E-Business Technology

Page 35: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Function Based Index: Pros. and Cons.Function Based Index: Pros. and Cons.

Pros.

Index scan for transformed value is possible

Cons.

DML overhead

Flexibility of index is low

– Only used for where cluases in predefined form

Center for E-Business Technology

Page 36: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Random AccessRandom Access

Random Access

IO single Block

Should be reduced

Table Full Scan

Multi Block IO

– Not Random Access

Index Scan

Random Access occurs

Center for E-Business Technology

Page 37: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Reducing Random AccessReducing Random Access

Reducing Random Access

Optimizing Cluster Factor

Using Optimized Index

– Ex) SELECT name, date, item

FROM trans

WHERE id = ‘10’

AND date BETWEEN ‘200401’ AND ‘20040406’

Center for E-Business Technology

Page 38: Chap 5. Disk IO Distribution Chap 6. Index Architecture

Copyright 2008 by CEBT

Random Access and Index ScanRandom Access and Index Scan

Random Access and Index Scan

Table Access via Index Scan is Random Access

Index Scan itself is NOT Random Access

Index Scan below 3% of data in table is effective

– Over 3%, Full table Scan is effective

Center for E-Business Technology