Disk Controller To disk subsystem Rotational Delay Seek time Disk Block Block Size Disk Characteristics Capacity Rotational Speed (RPM) Seek Time Interface (SCSI, ATA, Serial ATA, Serial Attached SCSI, Fiber Channel)
b6 C101 Smith Joe Hanover NJ C102 Green Ed Lodi NY b7b8b9 Disk Block Record 1Record 2 Field separator Record separator b10b11b12b13 Disk Block and Record Storage Disk Block Record size (Fixed / Variable) Spanned vs. Unspanned Blocking Factor
b6 b7b8b9 b6b7b8b9 R1R2R3R4R5R6 R1R2R3R4R5R6 Unspanned Record Organization Spanned Record Organization Spanned vs. Unspanned Record Organization
FNAME LNAME EMPID DNO SALARY JOHN SMITH FRANKLIN WONG JOYCE ENGLISH RAMESH NARAYAN JAMES BORG JENNIFER WALLACE AHMAD JABBAR ALICIA ZELAYA I-Field Block Primary Index Block
FNAME LNAME EMPID DNO SALARY JOHN SMITH FRANKLIN WONG JOYCE ENGLISH RAMESH NARAYAN JAMES BORG JENNIFER WALLACE AHMAD JABBAR ALICIA ZELAYA I-Field Block Record Offset BORG ENGLISH JABBAR NARAYAN SMITH WALLACE WONG ZELAYA Secondary Index Block Record Pointer
FNAME LNAME EMPID DNO SALARY JAMES BORG JENNIFER WALLACE AHMAD JABBAR ALICIA ZELAYA JOHN SMITH FRANKLIN WONG JOYCE ENGLISH RAMESH NARAYAN I-Field Block Clustering Index Block I-Field Block Record Offset BORG ENGLISH JABBAR NARAYAN SMITH WALLACE WONG ZELAYA Secondary Index Record Pointer
B Tree Index NARAYAN ENGLISH WALLACE BORG ENGLISH JABBAR NARAYAN SMITH WALLACE WONG ZELAYA FNAME LNAME EMPID DNO SALARY JAMES BORG JENNIFER WALLACE AHMAD JABBAR ALICIA ZELAYA JOHN SMITH FRANKLIN WONG JOYCE ENGLISH RAMESH NARAYAN Block
B+ Tree Index NARAYAN ENGLISH WALLACE BORG ENGLISH JABBAR NARAYAN SMITH WALLACE WONG ZELAYA FNAME LNAME EMPID DNO SALARY JAMES BORG JENNIFER WALLACE AHMAD JABBAR ALICIA ZELAYA JOHN SMITH FRANKLIN WONG JOYCE ENGLISH RAMESH NARAYAN Block
B* Tree Index NARAYAN 104 ENGLISH 104 WALLACE 101 BORG ENGLISH JABBAR NARAYAN SMITH WALLACE WONG ZELAYA FNAME LNAME EMPID DNO SALARY JAMES BORG JENNIFER WALLACE AHMAD JABBAR ALICIA ZELAYA JOHN SMITH FRANKLIN WONG JOYCE ENGLISH RAMESH NARAYAN Block
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:
Data Index R1 … R14 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 = = 18 Blocks Second Index Level: 18 / 26 = 1 Block Total Number of Levels: 2 Levels (check with Log ) Total Size of Primary Index: (18 + 1) = 19 Blocks Block 1 R15 … R28 Block 2B3 … B4 … B26 … B27 … B52 …… B78 … B79 …R6200 B443 … B53 … I1 I2 I3 I4… I26 ……… I27 … I52I53 … I78I418 … I443 I1 I27 I53 … I418 … Example: Primary Index IB1IB2IB3IB17 1 st Level 2 nd Level
Data Index R1 … R14 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 Log ) Block 1 R15 … R28 Block 2B3 … B4 … B26 … B27 … B52 …… B78 … B79 …R6200 B443 … B53 … I1 I2 I3 I4… I25 ……… I51 … I75I6176 … I6200 I1 I626 …. I5626 … Example: Secondary Index IB1IB2 IB3 IB248 I26 … I50 I1 I26 I51 … I625 IB249 I626 … I1250 IB250 I5626 … I6176 IB258 IB259 1 st Level 2 nd Level 3nd Level
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 Data Block 1 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 Data Block 2 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 I1 I626 I1251 I1876 I2501 I3126 I3751 I4376 I5001 I5626 I6251 Example: Secondary Index – Close Up View IB1IB2 I1 I26 I51 I76 …. I526 I551 I576 I601 IB249 IB259 I26 I27 I28 I29 I30 I31 I32 I33 I34 … I626 I651 I676 I701 I726 …. I1176 I1201 I1226 IB250
FNAME LNAME SSN DNO SALARY JAMES BORG JOYCE ENGLISH AHMAD JABBAR RAMESH NARAYAN JOHN SMITH JENNIFER WALLACE FRANKLIN WONG ALICIA ZELAYA Block b1 b2 b3 b4 Ordered File
FNAME LNAME SSN DNO SALARY RAMESH NARAYAN ALICIA ZELAYA JAMES BORG JOHN SMITH JENNIFER WALLACE FRANKLIN WONG AHMAD JABBAR JOYCE ENGLISH Block b1 b2 b3 b4 Unordered File
FNAME LNAME SSN DNO SALARY RAMESH NARAYAN ALICIA ZELAYA JAMES BORG JOHN SMITH JENNIFER WALLACE FRANKLIN WONG AHMAD JABBAR JOYCE ENGLISH Block b1 b2 b3 b4 Indexed File I-Value Block BORG b2 ENGLISH b4 JABBAR b4 NARAYAN b1 SMITH b2 WALLACE b3 WONG b3 ZELAYA b1 Index Record Pointer