Disk structure and access time in DBMS Theory - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
When working with disks in databases, it is important to understand how long it takes to read or write data.
We want to know how the time to access data grows as the amount of data or disk structure changes.
Analyze the time complexity of accessing a block on a disk.
-- Steps to access a disk block
seek to track position
wait for disk rotation to sector
read the block into memory
This shows the main steps involved in reading a block from a disk.
Look at what repeats or takes time during disk access.
- Primary operation: Moving the disk head to the correct track (seek) and waiting for the disk to rotate to the right sector (rotational delay).
- How many times: Each block access requires these steps once, but if multiple blocks are read, these steps repeat for each block.
As you read more blocks, the total time grows roughly with the number of blocks.
| Number of Blocks (n) | Approx. Total Access Time |
|---|---|
| 10 | 10 times seek + rotation + read time |
| 100 | 100 times seek + rotation + read time |
| 1000 | 1000 times seek + rotation + read time |
Pattern observation: The total time increases roughly in direct proportion to the number of blocks accessed.
Time Complexity: O(n)
This means the total time to access data grows linearly with the number of blocks you want to read.
[X] Wrong: "Accessing more blocks takes the same time as accessing one block because the disk is fast."
[OK] Correct: Each block requires moving the disk head and waiting for rotation, so more blocks mean more time.
Understanding disk access time helps you explain how databases manage data efficiently and why some operations take longer.
"What if the disk used solid-state technology with no moving parts? How would the time complexity change?"
Practice
Solution
Step 1: Understand disk access time components
Disk access time includes seek time (moving the head), rotational latency (waiting for the sector), and transfer time (reading/writing data).Step 2: Identify the unrelated component
Cache size is related to memory and buffering, not directly part of disk access time.Final Answer:
Cache size -> Option DQuick Check:
Disk access time excludes cache size [OK]
- Confusing cache size with access time
- Including CPU time as access time
- Mixing memory and disk terms
Solution
Step 1: Recall disk physical structure
Disks are physically divided into circular tracks and each track is divided into sectors.Step 2: Match terms with disk structure
Blocks, pages, clusters, bytes, frames, and segments are terms used in memory or file systems, not the physical disk layout.Final Answer:
A disk is divided into tracks and sectors -> Option AQuick Check:
Disk = tracks + sectors [OK]
- Confusing file system units with disk physical units
- Mixing memory terms with disk terms
Solution
Step 1: Add all components of access time
Total access time = seek time + rotational latency + transfer time = 4 ms + 3 ms + 2 ms.Step 2: Calculate the sum
4 + 3 + 2 = 9 ms total access time.Final Answer:
9 ms -> Option BQuick Check:
4 + 3 + 2 = 9 ms [OK]
- Forgetting to add all three times
- Mixing units
- Adding only two components
Solution
Step 1: Understand the components of access time
Access time includes seek time, rotational latency, and transfer time. Ignoring rotational latency misses part of the delay.Step 2: Effect of ignoring rotational latency
Ignoring rotational latency means the total time is less than actual, so the access time is underestimated.Final Answer:
The access time will be underestimated -> Option AQuick Check:
Missing rotational latency lowers total time [OK]
- Ignoring rotational latency
- Assuming transfer time covers all delays
- Confusing seek time with rotational latency
Solution
Step 1: Understand the proportionality
Average seek time ∝ √(number of tracks). Given seek time for 2500 tracks is 4 ms.Step 2: Calculate seek time for 5000 tracks
Ratio of seek times = √5000 / √2500 = √2 ≈ 1.414. So, new seek time = 4 ms x 1.414 ≈ 5.66 ms.Final Answer:
5.66 ms -> Option CQuick Check:
Seek time scales with sqrt(tracks) [OK]
- Using linear ratio instead of square root
- Mixing up track counts
- Forgetting to multiply by original time
