Unit Iii
Unit Iii
Unit Iii
Secondary Storage:
These devices usually have a large capacity.
Less cost and slower access to data
It is non-volatile.
E.g.: Magnetic disks
Tertiary Storage:
This is in the lowest level of hierarchy.
Non-volatile,
Slow access time
Example: Magnetic tape, optical storage
Cache Memory
It is the fastest and most costly form of storage.
It is volatile in nature.
Seek time: Time it takes to reposition the arm over the correct
track. The seek time ranges from 2 to 30 milliseconds. The
average seek time is one-third the worst case seek time and one
half the maximum seek time. Average seek time currently ranges
between 4 to 10 milliseconds.
Rotational latency: Time it takes for the sector
to be accessed to appear under the head. It
ranges from 4 to 11 milliseconds.
Typically 3 to 5 years
Scheduling
Disk arm scheduling algorithm order pending accesses to tracks
so that disk arm movement is minimized.
Commonly used algorithm is elevator algorithm.
Move disk arm in one direction (From outer to inner tracks or
vice versa), processing next request in that direction, till no
more requests in that direction, then reverse direction and repeat.
File organization:
Optimize block access time by organizing the blocks to
correspond to how data will be accessed.
Eg: store related information’s on the same or nearby
cylinders.
Sequential file may become fragmented, that is its blocks
become scattered all over the disk. Sequential access to a
fragmented file results in increased disk arm movement.
Non-volatile write buffers: (NV-RAM)
To speed up disk writes by writing blocks to a non-
volatile RAM buffer immediately, the contents to
NV-RAM are not lost in power failure.
Log disk
A disk devoted to writing a sequential log to block
updates used exactly like non-volatile RAM. Write to
log disk is very fast since no seeks are required
Journaling file system write data in safe order to NV-
RAM or log disk.
RAID
Deletion – If we want to delete a record, Using the hash function we will first
fetch the record which is supposed to be deleted. Then we will remove the
records for that address in memory.
Updation – The data record that needs to be updated is first searched using
hash function, and then the data record is updated.
• Now, If we want to insert some new records into the file But
the data bucket address generated by the hash function is not
empty or the data already exists in that address. This becomes
a critical situation to handle. This situation in the static
hashing is called bucket overflow.
101 102 bb 20
120
130
2 24
8 29
15
24 35
36
2 35
35 39 51
55 44 53
85 51
55
55
61
63
71 80
80 82
B+ Tree
Leaf node
• The leaf node of the B+ tree can contain at least n/2 record
pointers and n/2 key values.
• At most, a leaf node contains n record pointer and n key values.
• Every leaf node of the B+ tree contains one block pointer P to
point to next leaf node.
Searching a record in B+ Tree
• Suppose we have to search 55 in the below B+ tree structure.
First, we will fetch for the intermediary node which will direct
to the leaf node that can contain a record for 55.
Evaluation:
The query execution engine takes a query evaluation,
executes that plan and returns the answers to the query.
Measures of Query Cost
Many factors contribute to time cost
Disk accesses, CPU, or even network communication
end
end
Algorithm for JOIN Operation
seeks
Merge Join
Sort both relations on their join attribute (if not already sorted
on the join attributes).
Merge the sorted relations to join them.
Hash Join:
The hash function is used h is used to partition tuples of
both the relations.
Cost: 3(br+bs)+4 x n block transfers + 2 ( [br/bb]+[bs/bb])
seeks.
Query Optimization
Heuristic Estimation:
Heuristic is a rule that leads to least cost in most of cases.
Systems may use heuristic to reduce the number of choices
that must be made in a cost-based fashion.
Heuristic optimization transforms the query-tree by using
a set of rules that typically t improve execution
performance.
Query Optimization
Query Tree:
SELECT schedule, room FROM Student NATURAL
JOIN Enroll NATURAL JOIN Class WHERE
Major='Math'
Query Optimization
Query Tree:
Query Optimization
File Size
Organization
Attribute selectivity.