390 likes | 608 Views
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
E N D
Chap 5. Disk IO DistributionChap 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 • B+-Tree Index • Bitmap Index • Reverse Key Index • Function Base Index • Random Access Tuning Center for E-Business Technology
Disk 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
Disk 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? • Optimizing Disk Organization • Segment Extent Striping • Applying Table Archtecture • Partition table, IOT table Center for E-Business Technology
Optimizing 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
Optimizing 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
Optimizing Disk Organization: Logical Volume Striping • Logical Volume Striping Center for E-Business Technology
Optimizing Disk Organization: Logical Volume Striping • 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
Oracle Storage Architecture Center for E-Business Technology
Oracle 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
Segment Extent Striping: Create Tablespace Center for E-Business Technology
Segment Extent Striping: Create Table on Tablespace Center for E-Business Technology
Segment Extent Striping: Create Table on Tablespace Center for E-Business Technology
Segment 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
Partition 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
Partition Table: Example • Result • Data about 20~30s are distributed to all 96 disks! Center for E-Business Technology
Wrong IO Distrubution #1 Center for E-Business Technology
Wrong IO Distribution #2 • Incrementally adding datafile to tablespace Center for E-Business Technology
Pros. and Cons. ofIndexing • Pros. • Improving Retrieving Performance • Cons. • Degrading Data Manipulation Performance • Insert, Delete, … • Storage Center for E-Business Technology
ROWID • ROWID • ID given to all rows in database Center for E-Business Technology
Example of ROWID Center for E-Business Technology
Usage of ROWID • Index Creation • Data Access • SQL Tuning Center for E-Business Technology
Index • B+-Tree Index • Bitmap Index • Reverse Key Index • Function Based Index Center for E-Business Technology
B+-Tree Index • B+-Tree Index • Support efficient search, delete, and insert Center for E-Business Technology
B+-Tree Index Access Center for E-Business Technology
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
Bitmap Index • Bitmap Index • Good for column with low cardinality Center for E-Business Technology
Bitmap Index structure Center for E-Business Technology
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
Reversed 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
Reversed Key Index: Pros. and Cons. • Pros. • Avoid competetion on left block • Cons. • Range scan is impossible Center for E-Business Technology
Function 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
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
Random 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
Reducing 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
Random 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