Ch03 Blocking

Click here to load reader

  • date post

  • Category


  • view

  • download


Embed Size (px)

Transcript of Ch03 Blocking

BlockingFakultas Informatika ITTelkom 2010


Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management


Buffer Management in a DBMSPage Requests from Higher LevelsBUFFER POOL disk page free frame MAIN MEMORY DISK


choice of frame dictated by replacement policy

Data must be in RAM for DBMS to operate on it! Buffer Mgr hides the fact that not all data is in


Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management


Records and Files

Blocks are the interface for I/O, but Higher levels of DBMS operate on records, and files of records. A record is one unit of structured data

tuple in a relation node in a tree or index object or other structure

Records may be fixed length or variable length A file is a set or records stored as a unit on diska file is stored on some set of disk blocks

A spanning file organization allows records to be split among blocks A non-spanning file organization requires whole records to be stored in a single

Blocking Blocking: storing a number of records in one block on the disk. Blocking factor (bfr) refers to the number of records per block. non-spanning organization: There may be empty space in a block if an integral number of records do not fit in one block.

Blocks and Pages A page is a unit of data transfer from the DBMS point of view Disk blocks are the smallest practical page size Larger pages are also possible:

all data on one track all data on one cylinder same block, same cylinder on all surfaces

typical page size: 1-10 Kbytes typical page transfer time (ptt): 1-10 msec

Record Blocking The logical unit of file is byte or record, and the physical unit of file is block. Block type: Fixed blocking Variable-length spanned blocking Variable Variable-length unspanned blocking Variable-

Record Blocking Choose fixed length or variable length Fixed is higher efficiency of I/O transfer ,memory allocation . How to choose the size of block Large blocking is efficiency (because of locality) for transfer, but needs more disk-cash disk-

Fixed Blocking (Fixed-Length Records)

Fixed Blocking (Fixed-Length Records)

Record length = block size There isnt wasted block Hard to be implemented Need more time to read records in 2 blocks There must be a Pointer Block (P) in each block Block efective size = B-P Record size + marker = R + M Bfr = (B-P) / (R+M) If M = P then Bfr = (B-P) / (R+P)

Variable Blocking - Unspanned VariableVariable-length records , unspanned

Variable Blocking Unspanned

Variable-length record Record cant be split into blocks wasted blocks Rekord length WR W = WG + WR W = WG

W on Variabel Spanned

There isnt wasted space because of blocking There is Record Marker (M) and pointer block (P) WR = M + P/Bfr W = WG + WR G / Bfr + M + (P/Bfr) W = M + (P+G)/Bfr If M = P, then W = P + (P+G)/Bfr

W on Variabel Unspanned There is wasted space and Record Marker WR = M + (( R)/Bfr) W = WG + WR G/Bfr + M + (( R)/Bfr) W = M + (1/2R + G)/Bfr If M = P, P + (1/2R + G)/Bfr

Spanned Vs Unspanned Records When the records in a file is stored on a disk they may be placed in blocks of a fixed size. This will rarely match the record size. So a decision must be made when the record size is smaller than the block size and the block size is not a multiple of the record size whether to store the record all in one block and have unused space or in two different blocks.

Chapter 5

2 0

Transfer Rate Transfer rate (t)

the rate at which data can be retrieved from or stored to the disk.

There is 2 transfer rate :

Rekord transfer time (TR) Time to transfer record with length R Block transfer time (btt) Time to transfer B block

TR = R / t

btt = B/t

Bulk transfer rate

To read larger data, used bulk transfer rate (t) t = (t/2) (R/(R+W))

Conclusion Variable length is efficient of storage but is difficult to implement. implement. VariableVariable-size or fixed-size fixedvariable large complexity but efficiency efficiency for transfer LargeLarge-size or small-size small-


Need the maximum size for the file at the time of creation Difficult to reliably estimate the maximum potential size of the file Tend to overestimated file size so as not to run out of space

Methods of File Allocation (1) Contiguous allocation Single set of blocks is allocated to a file at the time of creation Only a single entry in the file allocation table Starting block and length of the file External fragmentation will occur

Methods of File Allocation (2) Chained allocation Allocation on basis of individual block Each block contains a pointer to the next block in the chain Only single entry in the file allocation table Starting block and length of file No external fragmentation Best for sequential files No accommodation of the principle of locality

Methods of File Allocation (3) Indexed allocation File allocation table contains a separate oneonelevel index for each file The index has one entry for each portion allocated to the file The file allocation table contains block number for the index

ExerciseDiketahui sebuah harddisk memiliki karakteristik : - seek time = 10ms - kecepatan putar disk 6000 rpm - Transfer rate = 2048 byte/s - kapasitas block = 2048 byte - ukuran rekord = 250 byte - ukuran gap = 256 byte - ukuran M = P = 8


a. b. c. d. e.

Blocking Factor Rekord Transfer Time Block transfer time Pemborosan Ruang (Waste) Bulk Transfer Rate

Jika metode blockingnya 1. Fixed blocking 2. Variable Spanned 3. Varible

PembahasanMetode Fixed Blocking a. Blocking Factor (Bfr) = B/R = 2048/ 250 = 8 b. Record Transfer Time (TR) = R/t = 250 / 2048 = 0.122 ms c. Block Transfer Time (btt) = B/t = 2048 / 2048 = 1 ms d. W = WG = G/Bfr = 256 / 8 = 32 byte e. Bulk Transfer Rate (t) = (t/2) (R/(R+W)) = (2048/2) (250/(250+32)) = (1024) (250/282) = 1024(0.886) = 907.8 ms

Latihan Soal

Bagaimana jika kasus di atas digunakan : - Metoda variable Unspanned - Metoda Spanned blocking Kerjakan sebagai Latihan Soal