Professional Documents
Culture Documents
Context
Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management
DB www.ittelkom.ac.id
DB
Data must be in RAM for DBMS to operate on it! Buffer Mgr hides the fact that not all data is in RAM
www.ittelkom.ac.id
Context
Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management
DB www.ittelkom.ac.id
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
Records may be fixed length or variable length A file is a set or records stored as a unit on disk
a 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 block
www.ittelkom.ac.id
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.
www.ittelkom.ac.id
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
www.ittelkom.ac.id
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-
www.ittelkom.ac.id
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-
www.ittelkom.ac.id
www.ittelkom.ac.id
Record length <= Block size Blocking factor Bfr = B R There is wasted blocks
www.ittelkom.ac.id
www.ittelkom.ac.id
Variable-length record Record can be split if there is Gap between block Rekord 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)
www.ittelkom.ac.id
www.ittelkom.ac.id
Variable-length record Record cant be split into blocks wasted blocks Rekord length <=block size Average wasted block = R There isnt Pointer block Block efective size = B - 1/2R Bfr = (B-1/2R)/(R+M)
there is
www.ittelkom.ac.id
www.ittelkom.ac.id
W on Fixed Blocking
In Fixed Blocking, wasted space because blocking < R For each record 0 WR < R/Bfr Fixed Blocking is used if record size << block capasity WG >> WR W = WG + WR W = WG
www.ittelkom.ac.id
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
www.ittelkom.ac.id
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
www.ittelkom.ac.id
www.ittelkom.ac.id
Chapter 5
2 0
Transfer Rate
Transfer rate (t)
the rate at which data can be retrieved from or stored to the disk.
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
To read larger data, used bulk transfer rate (t) t = (t/2) (R/(R+W))
www.ittelkom.ac.id
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-
www.ittelkom.ac.id
Pre-Allocation
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
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
www.ittelkom.ac.id
Exercise
Diketahui 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 byte
www.ittelkom.ac.id
???
a. b. c. d. e.
Blocking Factor Rekord Transfer Time Block transfer time Pemborosan Ruang (Waste) Bulk Transfer Rate
Pembahasan
Metode 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
www.ittelkom.ac.id
Latihan Soal
Bagaimana jika kasus di atas digunakan : - Metoda variable Unspanned - Metoda Spanned blocking Kerjakan sebagai Latihan Soal
www.ittelkom.ac.id
TERIMA KASIH
www.ittelkom.ac.id