170 likes | 539 Views
Disk Characteristics. Rotational Delay. To disk subsystem . Disk Controller. Disk Block Block Size. Seek time. Capacity Rotational Speed (RPM) Seek Time Interface (SCSI, ATA, Serial ATA, Serial Attached SCSI, Fiber Channel). Disk Block and Record Storage. Disk Block
E N D
Disk Characteristics Rotational Delay To disk subsystem Disk Controller Disk Block Block Size Seek time Capacity Rotational Speed (RPM) Seek Time Interface (SCSI, ATA, Serial ATA, Serial Attached SCSI, Fiber Channel)
Disk Block and Record Storage Disk Block Record size (Fixed / Variable) Spanned vs. Unspanned Blocking Factor b6 b7 b8 b9 b10 b11 b12 b13 Disk Block C101^Smith^Joe^Hanover^NJC102^Green^Ed^Lodi^NY Record 1 Record 2 Record separator Field separator
Spanned vs. Unspanned Record Organization Unspanned Record Organization R1 R2 R3 R4 R5 R6 b6 b7 b8 b9 Spanned Record Organization R1 R2 R3 R4 R5 R6 b6 b7 b8 b9
Block 101 102 103 104 FNAME LNAME EMPID DNO SALARY JOHN SMITH 123456789 5 30000 FRANKLIN WONG 333445555 5 40000 JOYCE ENGLISH 453453453 5 25000 RAMESH NARAYAN 666884444 5 38000 JAMES BORG 888665555 1 55000 JENNIFER WALLACE 987654321 4 43000 AHMAD JABBAR 987987987 4 25000 ALICIA ZELAYA 999887777 4 25000 Primary Index I-Field Block 123456789 101 453453453 102 888665555 103 987987987 104
Block 101 102 103 104 FNAME LNAME EMPID DNO SALARY JOHN SMITH 123456789 5 30000 FRANKLIN WONG 333445555 5 40000 JOYCE ENGLISH 453453453 5 25000 RAMESH NARAYAN 666884444 5 38000 JAMES BORG 888665555 1 55000 JENNIFER WALLACE 987654321 4 43000 AHMAD JABBAR 987987987 4 25000 ALICIA ZELAYA 999887777 4 25000 Secondary Index Record Pointer I-Field Block Record Offset BORG 103 1 ENGLISH 102 1 JABBAR 104 1 NARAYAN 102 2 SMITH 101 1 WALLACE 103 2 WONG 101 2 ZELAYA 104 2
Block 101 102 103 104 FNAME LNAME EMPID DNO SALARY JAMES BORG 888665555 1 55000 JENNIFER WALLACE 987654321 4 43000 AHMAD JABBAR 987987987 4 25000 ALICIA ZELAYA 999887777 4 25000 JOHN SMITH 123456789 5 30000 FRANKLIN WONG 333445555 5 40000 JOYCE ENGLISH 453453453 5 25000 RAMESH NARAYAN 666884444 5 38000 Secondary Index Clustering Index Record Pointer I-Field Block Record Offset BORG 101 1 ENGLISH 104 1 JABBAR 102 1 NARAYAN 104 2 SMITH 103 1 WALLACE 101 2 WONG 103 2 ZELAYA 102 2 I-Field Block 1 101 4 101 5 103
Block 101 102 103 104 FNAME LNAME EMPID DNO SALARY JAMES BORG 888665555 1 55000 JENNIFER WALLACE 987654321 4 43000 AHMAD JABBAR 987987987 4 25000 ALICIA ZELAYA 999887777 4 25000 JOHN SMITH 123456789 5 30000 FRANKLIN WONG 333445555 5 40000 JOYCE ENGLISH 453453453 5 25000 RAMESH NARAYAN 666884444 5 38000 B Tree Index NARAYAN ENGLISH WALLACE BORG ENGLISH 101 104 JABBAR NARAYAN 102 104 SMITH WALLACE 103 101 WONG ZELAYA 103 102
Block 101 102 103 104 FNAME LNAME EMPID DNO SALARY JAMES BORG 888665555 1 55000 JENNIFER WALLACE 987654321 4 43000 AHMAD JABBAR 987987987 4 25000 ALICIA ZELAYA 999887777 4 25000 JOHN SMITH 123456789 5 30000 FRANKLIN WONG 333445555 5 40000 JOYCE ENGLISH 453453453 5 25000 RAMESH NARAYAN 666884444 5 38000 B+ Tree Index NARAYAN ENGLISH WALLACE BORG ENGLISH 101 104 JABBAR NARAYAN 102 104 SMITH WALLACE 103 101 WONG ZELAYA 103 102
Block 101 102 103 104 FNAME LNAME EMPID DNO SALARY JAMES BORG 888665555 1 55000 JENNIFER WALLACE 987654321 4 43000 AHMAD JABBAR 987987987 4 25000 ALICIA ZELAYA 999887777 4 25000 JOHN SMITH 123456789 5 30000 FRANKLIN WONG 333445555 5 40000 JOYCE ENGLISH 453453453 5 25000 RAMESH NARAYAN 666884444 5 38000 B* Tree Index NARAYAN 104 ENGLISH 104 WALLACE 101 BORG ENGLISH 101 104 JABBAR NARAYAN 102 104 SMITH WALLACE 103 101 WONG ZELAYA 103 102
Some Definitions • Block Size: Minimum Fixed sized unit that can be read or written on disk (in Bytes) • Record Size: Size of a data record for a particular table. Add together field/column sizes (in Bytes) • Blocking Factor: The number of data records than can fit in a data block (in Records per Block) • Index Entry Size: The size of an index entry calculated as either (in Bytes): • (Primary, Clustering) The size of the indexed column + size of the block pointer • (Secondary) The size of the indexed column + size of the block pointer + the size of the record offset • Fan Out: The number of index entries that can fit in a Block (in Index entries per block) • Number of first level index entries:
Example: Primary Index Block Size: 512 Bytes Record Size: 35 Bytes nRecords: 6200 bFactor: 512 / 35 = 14 rec/block nBlocks: 6200 / 14 = 443 blocks Index Entry Size: 19 Bytes Fan Out: 512 / 19 = 26 index entry/block First Index Level: 443 / 26 = 17.03846 = 18 Blocks Second Index Level: 18 / 26 = 1 Block Total Number of Levels: 2 Levels (check with Log26 443) Total Size of Primary Index: (18 + 1) = 19 Blocks I1 I27 I53 … I418 2nd Level Index … 1st Level I1 I2 I3 I4… I26 I27 … I52 I53 … I78 I418 … I443 IB1 IB2 IB3 IB17 R1 … R14 R15 … R28 … … … … … … … … … … … … …R6200 Data Block 1 Block 2 B3 B4 B26 B27 B52 B53 B78 B79 B443
Example: Secondary Index Block Size: 512 Bytes Record Size: 35 Bytes nRecords: 6200 bFactor: 512 / 35 = 14 rec/block nBlocks: 6200 / 14 = 443 blocks Index Entry Size: 20 Bytes Fan Out: 512 / 20 = 25 index entry/block First Index Level: 6200 / 25 = 248 Blocks Second Index Level: 248 / 25 = 10 Blocks Third Index Level: 10 / 25 = 1 Block Total Size: 259 Blocks Total Number of Levels: 3 Levels (check with Log25 6200) I1 I626 …. I5626 3nd Level IB259 2nd Level I626 … I1250 I5626 … I6176 I1 I26 I51 … I625 Index IB249 IB250 IB258 … I1 I2 I3 I4… I25 I26 … I50 I51 … I75 I6176 … I6200 1st Level IB3 IB1 IB2 IB248 R1 … R14 R15 … R28 … … … … … … … … … … … … …R6200 Data Block 1 Block 2 B3 B4 B26 B27 B52 B53 B78 B79 B443
Example: Secondary Index – Close Up View I1 I626 I1251 I1876 I2501 I3126 I3751 I4376 I5001 I5626 I6251 IB259 I626 I651 I676 I701 I726 …. I1176 I1201 I1226 I1 I26 I51 I76 …. I526 I551 I576 I601 IB249 IB250 I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 I12 I13 I14 I15 I16 I17 I18 I19 I20 I21 I22 I23 I24 I25 I26 I27 I28 I29 I30 I31 I32 I33 I34 … IB1 IB2 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 Data Block 1 Data Block 2
Ordered File Block b1 b2 b3 b4 FNAME LNAME SSN DNO SALARY JAMES BORG 888665555 1 55000 JOYCE ENGLISH 453453453 5 25000 AHMAD JABBAR 987987987 4 25000 RAMESH NARAYAN 666884444 5 38000 JOHN SMITH 123456789 5 30000 JENNIFER WALLACE 987654321 4 43000 FRANKLIN WONG 333445555 5 40000 ALICIA ZELAYA 999887777 4 25000
Unordered File Block b1 b2 b3 b4 FNAME LNAME SSN DNO SALARY RAMESH NARAYAN 666884444 5 38000 ALICIA ZELAYA 999887777 4 25000 JAMES BORG 888665555 1 55000 JOHN SMITH 123456789 5 30000 JENNIFER WALLACE 987654321 4 43000 FRANKLIN WONG 333445555 5 40000 AHMAD JABBAR 987987987 4 25000 JOYCE ENGLISH 453453453 5 25000
Indexed File Block b1 b2 b3 b4 FNAME LNAME SSN DNO SALARY RAMESH NARAYAN 666884444 5 38000 ALICIA ZELAYA 999887777 4 25000 JAMES BORG 888665555 1 55000 JOHN SMITH 123456789 5 30000 JENNIFER WALLACE 987654321 4 43000 FRANKLIN WONG 333445555 5 40000 AHMAD JABBAR 987987987 4 25000 JOYCE ENGLISH 453453453 5 25000 Index Record Pointer I-Value Block BORG b2 ENGLISH b4 JABBAR b4 NARAYAN b1 SMITH b2 WALLACE b3 WONG b3 ZELAYA b1